Skip to content

Commit 4c40df2

Browse files
committed
clarify meaning of selection sets
1 parent ac2f86e commit 4c40df2

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

Section 2 -- Language.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,31 +52,35 @@ Note: many examples below will use the query shorthand syntax.
5252

5353
## Fields
5454

55-
A field in the top-level selection set often represents some kind of
56-
information that is globally accessible to your application and the current
57-
viewer. Some typical examples of global fields:
55+
Fields represent information that is accessible to your application. Some
56+
typical examples include:
5857

5958
```graphql
6059
# `me` could represent the currently logged in user.
6160
query getMe {
6261
me {
63-
# ...
62+
name
6463
}
6564
}
6665

6766
# `user` represents one of many users in a graph of data.
6867
query getZuck {
6968
user(id: 4) {
70-
# ...
69+
name
7170
}
7271
}
7372
```
7473

74+
In these examples, `me` and `user` are top-level fields that represent globally
75+
accessible data and `name` is a subfield that represents data on a particular
76+
object.
77+
7578
## Field Selections
7679

77-
Each field is of a specific type, and the sub-fields must always be explicitly
78-
declared via a field selection, unless it is a scalar. For example, when
79-
fetching data from some user object:
80+
Each field is of a specific type, and the subfields must always be explicitly
81+
declared via a field selection, unless the field is a scalar. For example, when
82+
fetching data from some user object each desired subfield must be requested
83+
explicitly:
8084

8185
```graphql
8286
query getZuck {
@@ -88,6 +92,10 @@ query getZuck {
8892
}
8993
```
9094

95+
In this query, the `id`, `firstname`, and `lastname` fields form the selection
96+
set of the `user` field. The top-level selection set is `user`, but could also
97+
include other top-level fields.
98+
9199
Field selections can be further composed to explicitly state all subfields of
92100
nested types. All queries must specify down to scalar fields.
93101

0 commit comments

Comments
 (0)