Eduflow
Search…
Fragments
Reuse fields for the same object type
You can also reuse chunks of your queries with GraphQL fragments:
With fragments
Without fragments
Results
1
fragment ReuseableFragment on Course {
2
id
3
title
4
flows {
5
title
6
}
7
}
8
9
{
10
course(id: "00000000-5945-95c7-65fc-a9747b20031d") {
11
...ReuseableFragment
12
}
13
anotherCourse: course(id: "00000000-5945-95c6-65fc-a9747b200320") {
14
...ReuseableFragment
15
}
16
}
Copied!
1
{
2
course(id: "00000000-5945-95c7-65fc-a9747b20031d") {
3
id
4
title
5
flows {
6
title
7
}
8
}
9
anotherCourse: course(id: "00000000-5945-95c6-65fc-a9747b200320") {
10
id
11
title
12
flows {
13
title
14
}
15
}
16
}
Copied!
1
{
2
"data": {
3
"course": {
4
"id": "00000000-5945-95c6-65fc-a9747b200317",
5
"title": "History 101",
6
"flows": [
7
{
8
"title": "Welcome to History 101"
9
},
10
{
11
"title": "Nascent Civilization"
12
}
13
]
14
},
15
"anotherCourse": {
16
"id": "00000000-5945-95c7-65fd-a9747b200320",
17
"title": "M & A 101",
18
"flows": [
19
{
20
"title": "Welcome to Mergers & Acquisitions 101"
21
},
22
{
23
"title": "Flow 1 - SEC Regulatory Measures"
24
},
25
{
26
"title": "Flow 2 - Intro"
27
},
28
{
29
"title": "Flow 3 - Mergers"
30
},
31
{
32
"title": "Flow 4 - Acquistions"
33
},
34
{
35
"title": "Mergeable activities"
36
}
37
]
38
}
39
}
40
}
Copied!
Another thing to point out: anotherCourse is a GraphQL alias. This is a way to make multiple queries to the same field (query.course)
Last modified 8mo ago
Copy link