Precise data fetching
Request only the properties a screen needs from an object.
GraphQL · Class
A GraphQL field is a selectable piece of data on an object. Fields can be nested to traverse related objects, accept arguments, and be aliased in the response.
A GraphQL field represents one piece of data requested from an object. Queries begin at a root operation field and can traverse related object fields; scalar or enum fields terminate the selection, while fields returning objects require a nested selection set.
fieldName
fieldName(argument: value)
aliasName: fieldNameA field returns the value described by its schema type; leaf fields return scalar or enum values, while object fields return nested data selected by the client.
query {
hero {
name
friends {
name
}
}
}This query selects scalar fields directly and traverses the related friends field with its own nested selection set.
Request only the properties a screen needs from an object.
Fetch an object and its related objects in one operation.
Request multiple variants of one field using distinct arguments.
A field is a selectable piece of information on a GraphQL object. The client names the fields it wants, and the response follows that requested shape.
Follow-up: How does a client query a field that returns an object? It must add a nested selection set identifying the fields to fetch from that object.
A field that returns a scalar or enum can be selected directly as a leaf. A field returning an object represents a relationship or structured value and needs further fields selected beneath it.
Follow-up: Why are nested selections useful? They let one request traverse related objects and retrieve connected data without separate round trips.
Fields may take arguments, which alter their output. Aliases can rename response keys and allow the same field to appear more than once with different arguments.
Follow-up: How can dynamic argument values be supplied? Declare a variable in the operation and pass that variable to the field argument.
QueriesSelection setsFieldsArgumentsAliasesVariablesSchemas and Types