Skip to content

Commit

Permalink
Subscription validation rule: single root field
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Zhu committed May 2, 2017
1 parent d0583ed commit 4bba743
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions spec/Section 5 -- Validation.md
Expand Up @@ -198,6 +198,70 @@ query getName {
}
```

### Subscription Operation Definitions

#### Single root field

**Formal Specification**

* For each subscription operation definition {subscription} in the document
* Let {rootFields} be the first level of fields on the operation's selection set.
* {rootFields} must be a set of one.

This comment has been minimized.

Copy link
@tcr

tcr May 2, 2017

s/set/list/ possibly

This comment has been minimized.

Copy link
@robzhu

robzhu May 2, 2017

Owner

"set of one" is consistent with the wording used in the rest of this doc.


**Explanatory Text**

Subscription operation must have exactly one root field.

Valid examples:

```graphql
subscription sub {
newMessage {
body
sender
}
}
```

```graphql
fragment newMessageFields on Message {
body
sender
}

subscription sub {
newMessage {
... newMessageFields
}
}
```

Invalid:

```!graphql
subscription sub {
newMessage {
body
sender
}
# a second root field will cause this operation to fail validation
alarms {
name
snoozeCount
}
}
```

```!graphql
subscription sub {
newMessage {
body
sender
}
# this also applies to introspection fields
__typename
}
```

## Fields

Expand Down

0 comments on commit 4bba743

Please sign in to comment.