Field selection occurs when you have a compound type (an object or interface type) and you select a set of sub fields from that type.
For example given the following query :
The field selection set of the
user field is
Knowing the field selection set can help make
DataFetchers more efficient. For example in the above query
imagine that the
user field is backed by an SQL database system. The data fetcher could look ahead into the field selection
set and use different queries because it knows the caller wants friend information as well as user information.
graphql.schema.DataFetchingFieldSelectionSet is used to represent this field selection set. It gives you maps
of the fields and their
graphql.schema.GraphQLFieldDefinitions and argument values.
A glob path matching system is used for addressing fields in the selection. Its based on
as an implementation.
This will allow you to use
? as special matching characters such that
invoice field with child fields that start with
customer. Each level of field is separated by
/ just like
a file system path.
There are methods that allow you to get more detailed information about the fields in the selection set. For example
if you are using Relay often you want to know what fields have
been request in the
Connection section of the query.
So given a query like:
you can write code that gets the details of each specific field that matches a glob.