Skip to content

Commit

Permalink
Merge pull request #99 from facebook/optional-op-name
Browse files Browse the repository at this point in the history
[RFC] Make operation name optional.
  • Loading branch information
leebyron committed Oct 1, 2015
2 parents 139a0a0 + 02af0fd commit d81fd1e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
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

0 comments on commit d81fd1e

Please sign in to comment.