What do 3 dots/periods/ellipsis in a relay/graphql query mean?
There are two uses of ...
related to fragments.
Incorporating a fragment by reference
query Foo {
user(id: 4) {
...userFields
}
}
fragment userFields on User {
name
}
Has the effect of composing the fields from the fragment into the embedding query:
query Foo {
user(id: 4) {
name
}
}
Note that fragments may compose other fragments.
Inline fragments
From the docs:
If you are querying a field that returns an interface or a union type, you will need to use inline fragments to access data on the underlying concrete type.
https://graphql.org/learn/queries/#inline-fragments
These can be used to compose fields in a type-dependent way. For example:
query Foo {
profile(id: $id) {
url
... on User {
homeAddress
}
... on Business {
address
}
}
}
In this example, the server will determine whether to return the homeAddress
or address
field at runtime, based on whether the requested object is a User
or a Business
.
Ah. It's explained here:
Fragments are consumed by using the spread operator (...). All fields selected by the fragment will be added to the query field selection at the same level as the fragment invocation. This happens through multiple levels of fragment spreads.