-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Teach prettier/graphql about formatting fragment variables. #6016
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
Conversation
Fragment variables are an experimental extension to GraphQL schema. Formatting should follow the same rules as formatting an OperationDefinition node, hence code is the same.
Do you think it would be bad to enable this by default and removing the option? |
Not really, gql parser should be robust enough to not cause issues. If this feature gets deleted in the future we will pick it up and fix when upgrading graphql-js dependency. It is strictly a superset of existing language so should work fine. Not sure what is the sentiment about using something that is experimental. |
In the JS parser, we support (I believe) all the syntax proposals Babel does, so I think we should do the same here. |
Can you add a test with multiple fragment variables so the variable section is forced to break onto multiple lines? |
Sorry to not have asked for all these things at once. How are the fragment variables specified when using the fragment? Does there need to be printing support for that too? |
They are now defined on the root operation definition through a query transformation at build time. You don’t set them at fragment spreads as of yet, so no extra work is necessary at this point |
The problem is if any of those proposals get deleted in the future (or maybe they stop working eventually). Prettier will either have to continue to support those (unfortunate) or stop formatting user's code (which is unfortunate for users). We already carry the burden of having to support both of decorator proposals. For this PR, I think we should do it and, if this doesn't get added to the language, let's hope the parser continues to support it for a while |
Should we have a policy that semver doesn’t apply to stage-x JS features? |
@j-f1 What? |
@duailibe we need this for our GraphQL usage at Facebook. Would it be possible to get it merged? Thanks! |
@duailibe referring to your previous comment above about supporting experimental features. I was wondering if we should have a policy that we’ll stay up to date with breaking changes to proposals for JS in minor versions. |
Thanks! |
Fragment variables are an experimental extension to GraphQL schema.
Formatting should follow the same rules as formatting an OperationDefinition node,
hence code is the same.
docs/
directory)CHANGELOG.unreleased.md
file following the template.✨Try the playground for this PR✨