Skip to content

Commit 567e05c

Browse files
authored
Editorial: Query shorthand (#841)
Clarify the rules for using query shorthand. Factored out of #777
1 parent 2c2cea7 commit 567e05c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

spec/Section 2 -- Language.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ LineTerminator ::
9898
- "Carriage Return (U+000D)" "New Line (U+000A)"
9999

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

105105
Note: Any error reporting which provides the line number in the source of the
@@ -151,7 +151,7 @@ Token ::
151151
- StringValue
152152

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

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

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

296297
**Query shorthand**
297298

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

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

0 commit comments

Comments
 (0)