9 GraphQL Variables
9 GraphQL Variables
9 GraphQL Variables
In this lesson, we will learn how to access the GraphQL schema and will introduce GraphQL variables and discuss
their importance.
Since we’re exploring queries and not mutations at the moment, select
“Query” in the “Docs” sidebar. Afterward, traverse the objects and fields of the
graph and explore their optional arguments. By clicking them, you can see the
accessible fields within those objects in the graph. Some fields are common
GraphQL types such as String , Int and Boolean , while some are custom like
the Organization type we used. In addition, you can see whether arguments
are required when requesting fields on an object; this can be identified by the
exclamation point. For instance, a field with a String! argument requires you
to pass in a String argument whereas a field with a simple String argument
doesn’t.
Environment Variables
Key: Value:
In the “Query Variables” panel, the variables would have the following
content for providing the organization variable as an argument for the query:
Environment Variables
Key: Value:
{
"organization": "the-road-to-learn-react"
}
Environment Variables
Key: Value:
Try to execute the previous query with two sets of variables: once with the
organization variable different from the default variable, and once without
defining the organization variable.