Selecting fields means explicitly specifying which fields of a type should be included in the response.
GraphQL requires the client to define the exact shape of the response by selecting fields.
Only the selected fields are returned by the server.
query {
user {
id
name
}
}
Response
{
"data": {
"user": {
"id": "1",
"name": "Zeeshan"
}
}
}
query {
user {
name
}
}
Response
{
"data": {
"user": {
"name": "Zeeshan"
}
}
}
Fields not requested are not returned.
If a field returns an object, its fields must also be selected.