- dynamic arguments, e.g. a selected item from a dropdown list, need to be stored in variables
- we need to define a
$variableName
and add it as a valid argument to the query
- we can then pass
variableName: value
into the function
query HeroNameAndFriends($episode: Episode) {
hero(episode: $episode) {
name
friends {
name
}
}
}
// The variable value is read from a dictionary, e.g. as a JSON file.
{
"episode": "JEDI"
}
// Default values are supplied in the type declaration
query HeroNameAndFriends($episode: Episode = JEDI)