Skip to content

Question about grammar #918

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

Open
sungam3r opened this issue Jan 6, 2022 · 1 comment
Open

Question about grammar #918

sungam3r opened this issue Jan 6, 2022 · 1 comment

Comments

@sungam3r
Copy link
Contributor

sungam3r commented Jan 6, 2022

Hi. I have long wanted to ask what these modifiers mean. I did not find explanations in the specification. Thanks.

изображение

@benjie
Copy link
Member

benjie commented Jan 11, 2022

Link to spec screenshotted above: https://spec.graphql.org/draft/#sec-Language.Arguments

Link to source: https://github.com/graphql/graphql-spec/blame/main/spec/Section%202%20--%20Language.md#L410

Arguments[Const] : ( Argument[?Const]+ )

The list is relatively straightforward to explain - it relates to the + in the grammar and means that it represents a list of that keyword (i.e. "Arguments is an open paren ( followed by a list of Argument followed by a close paren )")


For the [Const]:

Introduced via this PR: https://github.com/graphql/graphql-spec/pull/90/files

But specifically this commit: eeb1a2c

Description: "Ensure directives cannot reference variables in SDL"

This seems to be subscripting indicating that when you reference Arguments[Const] (i.e. when you write SDL), you cannot reference variables. If, however, Arguments is referenced without the [Const] subscript (e.g. Field) then variables are allowed.

To be more explicit, the following would be invalid:

type Query {
  str: String @deprecated(reason: $reason)
}

And that is enforced at a grammar level.

maartenvanvliet added a commit to maartenvanvliet/absinthe that referenced this issue Jan 19, 2022
The graphql spec (https://spec.graphql.org/draft/#sec-Appendix-Grammar-Summary.Source-Text)
declares that in some location a value cannot be a variable.

This is especially the case in the schema definition language, where
setting the values of directive arguments to a variable is not permitted.

Also in executable documents, setting the default value of a variable definition
to a variable is not permitted.

See graphql/graphql-spec#918 (comment)
for more on this.
maartenvanvliet added a commit to maartenvanvliet/absinthe that referenced this issue Jan 19, 2022
The graphql spec (https://spec.graphql.org/draft/#sec-Appendix-Grammar-Summary.Source-Text)
declares that in some location a value cannot be a variable.

This is especially the case in the schema definition language, where
setting the values of directive arguments to a variable is not permitted.

Also in executable documents, setting the default value of a variable definition
to a variable is not permitted.

See graphql/graphql-spec#918 (comment)
for more on this.
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