Skip to content

print_schema no more put a trailing new line #157

Closed
@wyfo

Description

@wyfo

Reporting issues with GraphQL-core 3

Release of version 3.2.0 triggered a dependabot PR on my repository, but all my tests are failing because print_schema behavior has changed and doesn't print a new line at the end of the printed schema. See yourself here.

My library can indeed be used to generate GraphQL schema, so most of my GraphQL related tests are making assertion on the printed schema; it's maybe not the best idea but I found it to be the simplest. For example, this test is now failing because of the missing trailing newline:

from dataclasses import dataclass

from graphql import print_schema

from apischema import type_name
from apischema.graphql import graphql_schema


@type_name("Foo")
@dataclass
class FooFoo:
    bar: int


def foo() -> FooFoo | None:
    ...


schema = graphql_schema(query=[foo])
schema_str = """\
type Query {
  foo: Foo
}

type Foo {
  bar: Int!
}
"""
assert print_schema(schema) == schema_str

I didn't found the reason of this change in the changelog and in a quick blame of print_schema.py, so I would like to simply ask you if this behavior is the expected one, as maybe GraphQL.js has changed its behavior too (I did not look at the detail of their changelog).

If it's indeed a regression, I'm ok to try to resolve it and submit a PR. Otherwise, I will just update all my tests, that's not a problem at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions