Query Operation with Variables

Learn how GraphQL variables help to prevent hardcoded arguments and make the query more flexible.

Until now, we’ve written all of our GraphQL parameters as query strings in the request. However, the arguments in a production application will usually be dynamic. For example, our application may have a dropdown menu with side dishes we, a search area, or a set of filters.

Variables in GraphQL

Instead of requiring the client to dynamically change the query string, GraphQL features an exclusive approach to extract dynamic values and set their values. These values are called variables.

How to convert hardcoded GraphQL queries

Let’s observe the GetPizzas query again.

Get hands-on with 1200+ tech skills courses.