Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print_schema no more put a trailing new line #157

Closed
wyfo opened this issue Jan 20, 2022 · 2 comments
Closed

print_schema no more put a trailing new line #157

wyfo opened this issue Jan 20, 2022 · 2 comments

Comments

@wyfo
Copy link

wyfo commented Jan 20, 2022

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.

@Cito
Copy link
Member

Cito commented Jan 20, 2022

Hi @wifo. This looks like caused by the change in #2997 that I ported to GraphQL-core, so it's the intended behavior now. Yes, I know, I should improve the changelogs so that they include all changes including those ported from GraphQL.js. Will try to do better.

@wyfo
Copy link
Author

wyfo commented Jan 20, 2022

This looks like caused by the change in #2997 that I ported to GraphQL-core, so it's the intended behavor now.

Perfect!

Yes, I know, I should improve the changelogs so that they include all changes including those ported from GraphQL.js.

You do what you have time to do, and your work is already marvellous. The fault is on my side, as I should have look at GraphQL.js changelog, as it was finally simple to find in it.

@wyfo wyfo closed this as completed Jan 20, 2022
wyfo added a commit to wyfo/apischema that referenced this issue Jan 28, 2022
wyfo added a commit to wyfo/apischema that referenced this issue Jan 28, 2022
wyfo added a commit to wyfo/apischema that referenced this issue Jan 28, 2022
* Bump graphql-core from 3.1.7 to 3.2.0 in /tests

Bumps [graphql-core](https://github.com/graphql-python/graphql-core) from 3.1.7 to 3.2.0.
- [Release notes](https://github.com/graphql-python/graphql-core/releases)
- [Commits](graphql-python/graphql-core@v3.1.7...v3.2.0)

---
updated-dependencies:
- dependency-name: graphql-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix trailing new lines in graphql schema

See graphql-python/graphql-core#157

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joseph Perez <joperez@hotmail.fr>
renahubbard519 added a commit to renahubbard519/apischema-benchmark-django-expert that referenced this issue Sep 16, 2022
* Bump graphql-core from 3.1.7 to 3.2.0 in /tests

Bumps [graphql-core](https://github.com/graphql-python/graphql-core) from 3.1.7 to 3.2.0.
- [Release notes](https://github.com/graphql-python/graphql-core/releases)
- [Commits](graphql-python/graphql-core@v3.1.7...v3.2.0)

---
updated-dependencies:
- dependency-name: graphql-core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix trailing new lines in graphql schema

See graphql-python/graphql-core#157

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joseph Perez <joperez@hotmail.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants