Skip to content
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 C -- Grammar Summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ OperationDefinition :

OperationType : one of `query` `mutation` `subscription`

SelectionSet : { Selection+ }
SelectionSet : { Selection\* }

Selection :

Expand Down
2 changes: 1 addition & 1 deletion spec/Section 2 -- Language.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ Note: many examples below will use the query shorthand syntax.

## Selection Sets

SelectionSet : { Selection+ }
SelectionSet : { Selection\* }

Selection :

Expand Down
7 changes: 3 additions & 4 deletions spec/Section 3 -- Type System.md
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ Where `name` is a field that will yield a {String} value, and `age` is a field
that will yield an {Int} value, and `picture` is a field that will yield a `Url`
value.

A query of an object value must select at least one field. This selection of
A query of an object value must be made via a selection set. This selection of
fields will yield an ordered map containing exactly the subset of the object
queried, which should be represented in the order in which they were queried.
Only fields that are declared on the object type may validly be queried on that
Expand Down Expand Up @@ -1933,9 +1933,8 @@ to denote a field that uses a Non-Null type like this: `name: String!`.
**Nullable vs. Optional**

Fields are _always_ optional within the context of a _selection set_, a field
may be omitted and the selection set is still valid (so long as the selection
set does not become empty). However fields that return Non-Null types will never
return the value {null} if queried.
may be omitted and the selection set is still valid. However fields that return
Non-Null types will never return the value {null} if queried.

Inputs (such as field arguments), are always optional by default. However a
non-null input type is required. In addition to not accepting the value {null},
Expand Down
20 changes: 18 additions & 2 deletions spec/Section 5 -- Validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -720,9 +720,9 @@ fragment conflictingDifferingResponses on Pet {
- For each {selection} in the document:
- Let {selectionType} be the unwrapped result type of {selection}.
- If {selectionType} is a scalar or enum:
- The subselection set of that selection must be empty.
- The subselection set of that selection must not be present.
- If {selectionType} is an interface, union, or object:
- The subselection set of that selection must not be empty.
- The subselection set of that selection must be present.
Comment thread
magicmark marked this conversation as resolved.

**Explanatory Text**

Expand All @@ -747,6 +747,14 @@ fragment scalarSelectionsNotAllowedOnInt on Dog {
}
```

An empty selection is a selection, so the following is also invalid.

```graphql counter-example
fragment scalarEmptySelectionsNotAllowedOnInt on Dog {
barkVolume {}
}
```

Conversely, non-leaf fields must have a field subselection. A non-leaf field is
any field with an object, interface, or union unwrapped type.

Expand Down Expand Up @@ -788,6 +796,14 @@ query directQueryOnObjectWithSubFields {
}
```

The subselection is permitted to be empty, so the following is also valid.

```graphql example
query directQueryOnObjectWithEmptySelection {
human {}
}
```

## Arguments

Arguments are provided to both fields and directives. The following validation
Expand Down
Loading