Skip to content

[RFC] Make operation name optional. #99

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
Oct 1, 2015
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion spec/Appendix B -- Grammar Summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Definition :

OperationDefinition :
- SelectionSet
- OperationType Name VariableDefinitions? Directives? SelectionSet
- OperationType Name? VariableDefinitions? Directives? SelectionSet

OperationType : one of query mutation

Expand Down
21 changes: 17 additions & 4 deletions spec/Section 2 -- Language.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ contain an operation. However documents which do not contain operations may
still be parsed and validated to allow client to represent a single request
across many documents.

If a query document contains only one query operation, that operation may be
represented in the shorthand form, which omits the query keyword and
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 query document contains multiple
operations, each operation must be named. When submitting a query document with
multiple operations to a GraphQL service, the name of the desired operation to
Expand All @@ -189,7 +189,7 @@ be executed must also be provided.
### Operations

OperationDefinition :
- OperationType Name VariableDefinitions? Directives? SelectionSet
- OperationType Name? VariableDefinitions? Directives? SelectionSet
- SelectionSet

OperationType : one of `query` `mutation`
Expand All @@ -199,7 +199,20 @@ There are two types of operations that GraphQL models:
* query - a read-only fetch.
* mutation - a write followed by a fetch.

Each operation is represented by an operation name and a selection set.
Each operation is represented by an optional operation name and a selection set.

For example, this mutation operation might "like" a story and then retrieve the
new number of likes:

```
mutation {
likeStory(storyID: 12345) {
story {
likeCount
}
}
}
```

**Query shorthand**

Expand Down