8000 AstPrinter: Empty types should not include braces `{}` by tinnou · Pull Request #3619 · graphql-java/graphql-java · GitHub
[go: up one dir, main page]

Skip to content

AstPrinter: Empty types should not include braces {}#3619

Merged
dondonz merged 1 commit intographql-java:masterfrom
tinnou:empty-type-print-fix
Jun 11, 2024
Merged

AstPrinter: Empty types should not include braces {}#3619
dondonz merged 1 commit intographql-java:masterfrom
tinnou:empty-type-print-fix

Conversation

@tinnou
Copy link
Contributor
@tinnou tinnou commented Jun 5, 2024

Description

In the latest version of the spec, empty types (input objects, object types) must be represented without curly braces, i.e the following is valid:

type Query 
# below only here to make the sdl valid 
extend type Query {
  foo: String
}

while the following technically isn't (note the {}):

type Query {}
# below only here to make the sdl valid 
extend type Query {
  foo: String
}

Because of historical reasons, graphql-java supports parsing of both syntaxes. However its AstPrinter prints the spec invalid form. While this is ok in systems where graphql-java's GraphQL parser is the only one in use, it fails in poly-parser systems where stricter (albeit spec-compliant) parsers might fail to parse graphql-java printed SDL output.

Approach

This PR updates the AstPrinter to be spec-compliant, i.e serialize empty types, empty selection sets (although should never happen) without the {}.

Follow ups

If there is interest, I can follow up with another PR that (while breaking backwards-compatibilty) will make the parser spec compliant as well, i.e only allow the form without braces {}.

Copy link
Member
@bbakerman bbakerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to see you contributing again :)

@tinnou
Copy link
Contributor Author
tinnou commented Jun 6, 2024

Great to see you contributing again :)

🙏 but really it's all you and the other core contributors that keep this library in tip-top shape!
@dondonz @andimarek 🤟

Copy link
Member
@dondonz dondonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@dondonz dondonz added this pull request to the merge queue Jun 11, 2024
Merged via the queue into graphql-java:master with commit 5ff0027 Jun 11, 2024
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

Successfully merging this pull request may close these issues.

3 participants

0