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

Fix printing object type definitions #1255

Conversation

swalkinshaw
Copy link
Collaborator

Directives come after the implemented interfaces.

See
https://github.com/graphql/graphql-js/blob/360fa06e43fed32b63fba99b353515e7b56eee20/src/language/printer.js#L117-L129
for the canonical printer.

This is pretty difficult to add a test for (I think?) and likely why there wasn't any to begin with.

@xuorig any suggestions for how to test this? Since right now we're building a document by parsing it but I don't think it supports directives like this?

@xuorig
Copy link
Contributor

xuorig commented Feb 1, 2018

oh damn 😨

AST nodes can have direcitves I think, so you could build your own using Nodes and print it.

Nodes::ObjectTypeDefinition.new(
  directives: ...,
  interfaces: ...,
)

would that work? You'll need to find the right objects for directives and interfaces (TypeNameNode i think there?) but it should work

@swalkinshaw swalkinshaw force-pushed the fix-printing-object-type-definition-directives branch from c4f178c to c5993ca Compare February 1, 2018 20:53
@swalkinshaw
Copy link
Collaborator Author

I was making it harder than it was. I just updated the existing kitchen sink schema to include this case.

Copy link
Contributor

@xuorig xuorig left a comment

Choose a reason for hiding this comment

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

thanks 🙏

@rmosolgo rmosolgo added this to the 1.7.10 milestone Feb 2, 2018
@rmosolgo
Copy link
Owner

rmosolgo commented Feb 2, 2018

👍

@rmosolgo rmosolgo merged commit 29cb07e into rmosolgo:master Feb 2, 2018
@swalkinshaw swalkinshaw deleted the fix-printing-object-type-definition-directives branch February 4, 2018 01:37
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