Using variable within a query
Prerequisites#
- configure GraphQL queries in which you want to pass the variable.
query GetHistory { __typename histories(limit: 10, offset: 10) { id flight { details } }}Directions#
- After writing your query, navigate to the
Variablesarea below the playground area. You can define the variable inJSON,FormandTableformat. You'll notice,Query-namewithVariablethat represent the current query variable. In our example, we have query-nameGetHistory, pass below variable in query variable are,
{ "limit": 10, "offset": 10}- Assign the same variable in
Explorertab with the$andvariable name, ie.$limit - Now pass the function argument with
variable nameandvariable-typeas per below reference code,
query GetHistory($limit: Int!, $offset: Int!) { __typename histories(limit: $limit, offset: $offset) { id flight { details } }}- Hit the play button.
You can now use any variable same as the above instructions.