Let's take a closer look at this query here to see what parts it consists of:
query PersonQuery { person(id: "cGVvcGxlOjE=") { name, gender, homeworld { name } } }
The first line defines an operation named PersonQuery
that queries data from the server, where the query
keyword is one of the three currently supported operations: query, mutation, and subscription.
Specifying the query
keyword and an operation name (PersonQuery
in this case) is only required when a GraphQL document defines multiple operations. We, therefore, could have written the previous query with a shorthand version:
{ person(id: "cGVvcGxlOjE=") { name, gender, homeworld { name } } }
The person
, name
, and homeworld
keywords are all query fields, where name
and gender
fields are considered to be leaf nodes of the query, requesting scalar values such as strings, Boolean values, and numbers; and person
and homeworld
are the fields that correspond...