Passing Argument Values Using Variables
Explore how to declare and use variables in GraphQL operations to pass argument values dynamically. Understand operation types like queries and mutations, and practice sending variables in JSON format to create flexible and reusable GraphQL requests.
We'll cover the following...
Using variables to pass argument values
GraphQL variables act as typed placeholders for values that will be sent along with the request. This concept may be familiar to you if you’ve used parameterized SQL queries for the insertion and sanitization of values. GraphQL variables are declared with their types before they’re used alongside the operation type. We haven’t had to think about operation types before, so let’s talk a little bit about what operations are and how they fit inside the GraphQL document.
Understanding operations
A GraphQL document consists of one or more operations, which model something we want the GraphQL server to do. Up to this point, we’ve asked the server to provide the information operation that GraphQL uses to call a query. GraphQL has other operation types, too, notably a mutation for persisting change to ...