Skip to content

Editorial: Query shorthand #841

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

Merged
merged 1 commit into from
Apr 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions spec/Section 2 -- Language.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ LineTerminator ::
- "Carriage Return (U+000D)" "New Line (U+000A)"

Like white space, line terminators are used to improve the legibility of source
text and separate lexical tokens, any amount may appear before or after any
other token and have no significance to the semantic meaning of a GraphQL
text and separate lexical tokens, any amount may appear before or after any
other token and have no significance to the semantic meaning of a GraphQL
Document. Line terminators are not found within any other token.

Note: Any error reporting which provides the line number in the source of the
Expand Down Expand Up @@ -151,7 +151,7 @@ Token ::
- StringValue

A GraphQL document is comprised of several kinds of indivisible lexical tokens
defined here in a lexical grammar by patterns of source Unicode characters.
defined here in a lexical grammar by patterns of source Unicode characters.
Lexical tokens may be separated by {Ignored} tokens.

Tokens are later used as terminal symbols in GraphQL syntactic grammar rules.
Expand Down Expand Up @@ -251,9 +251,10 @@ However documents which do not contain {OperationDefinition} or do contain
and validated to allow client tools to represent many GraphQL uses which may
appear across many individual files.

If a Document contains only one operation, that operation may be unnamed or
represented in the shorthand form, which omits both the query keyword and
operation name. Otherwise, if a GraphQL Document contains multiple
If a Document contains only one operation, that operation may be unnamed. If
that operation is a query without variables or directives then it may also be
represented in the shorthand form, omitting both the {`query`} keyword as well
as the operation name. Otherwise, if a GraphQL Document contains multiple
operations, each operation must be named. When submitting a Document with
multiple operations to a GraphQL service, the name of the desired operation to
be executed must also be provided.
Expand Down Expand Up @@ -295,9 +296,10 @@ mutation {

**Query shorthand**

If a document contains only one query operation, and that query defines no
variables and contains no directives, that operation may be represented in a
short-hand form which omits the query keyword and query name.
If a document contains only one operation and that operation is a query which
defines no variables and contains no directives then that operation may be
represented in a short-hand form which omits the {`query`} keyword and operation
name.

For example, this unnamed query operation is written via query shorthand.

Expand Down