Skip to content

Commit 2ffad17

Browse files
committed
Merge pull request #62 from tristanz/selection-sets
clarify meaning of selection sets
2 parents 5c5d80a + 4c40df2 commit 2ffad17

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
@@ -63,31 +63,35 @@ Note: many examples below will use the query shorthand syntax.
6363

6464
## Fields
6565

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

7069
```graphql
7170
# `me` could represent the currently logged in user.
7271
query getMe {
7372
me {
74-
# ...
73+
name
7574
}
7675
}
7776

7877
# `user` represents one of many users in a graph of data.
7978
query getZuck {
8079
user(id: 4) {
81-
# ...
80+
name
8281
}
8382
}
8483
```
8584

85+
In these examples, `me` and `user` are top-level fields that represent globally
86+
accessible data and `name` is a subfield that represents data on a particular
87+
object.
88+
8689
## Field Selections
8790

88-
Each field is of a specific type, and the sub-fields must always be explicitly
89-
declared via a field selection, unless it is a scalar. For example, when
90-
fetching data from some user object:
91+
Each field is of a specific type, and the subfields must always be explicitly
92+
declared via a field selection, unless the field is a scalar. For example, when
93+
fetching data from some user object each desired subfield must be requested
94+
explicitly:
9195

9296
```graphql
9397
query getZuck {
@@ -99,6 +103,10 @@ query getZuck {
99103
}
100104
```
101105

106+
In this query, the `id`, `firstname`, and `lastname` fields form the selection
107+
set of the `user` field. The top-level selection set is `user`, but could also
108+
include other top-level fields.
109+
102110
Field selections can be further composed to explicitly state all subfields of
103111
nested types. All queries must specify down to scalar fields.
104112

0 commit comments

Comments
 (0)