Eduflow
Search…
Variables

Variables

GraphQL offers a way to reuse your queries dynamically through variables. These will come into play especially if you're accessing the API programmatically (such as our Node or Python examples).
Before:
Query (no variables)
Response
1
{
2
course(id: "00000000-5945-95c7-65fd-a9747b200317") {
3
id
4
title
5
flows {
6
title
7
}
8
}
9
}
Copied!
1
{
2
"data": {
3
"course": {
4
"id": "00000000-5945-95c7-65fd-a9747b200317",
5
"title": "History of Dunder-Mifflin",
6
"flows": [
7
{
8
"title": "Founding a Company"
9
},
10
{
11
"title": "Corporate Citizenship"
12
}
13
]
14
}
15
}
16
}
Copied!
With variables:
Query (with variables)
Response
1
query($courseId: UUID!) {
2
course(id: $courseId) {
3
id
4
title
5
flows {
6
title
7
}
8
}
9
}
Copied!
1
{
2
"data": {
3
"course": {
4
"id": "00000000-5945-95c7-65fd-a9747b200317",
5
"title": "History of Dunder-Mifflin",
6
"flows": [
7
{
8
"title": "Founding A Company"
9
},
10
{
11
"title": "Corporate Citizenship"
12
}
13
]
14
}
15
}
16
}
Copied!
Here's an example of what this would look like in the API Explorer:
GraphiQL allows variables to be passed on the bottom-left pane.

See also

Last modified 8mo ago
Copy link
Contents
Variables