Eduflow
Search…
Inline fragments
GraphQL's permits polymorphism through inline fragments, through objects being available as GraphQL Unions and Interfaces. Eduflow uses inline fragments across the various activity object types.
Eduflow activities all have Activity.title, so all activities inherit from ActivityInterface.

Querying

Query
Response
1
{
2
course(id: "00000000-5945-95c7-65fc-a9747b200320") {
3
flows {
4
activities {
5
... on ActivityInterface {
6
title
7
}
8
}
9
}
10
}
11
}
Copied!
1
{
2
"data": {
3
"course": {
4
"flows": [
5
{
6
"activities": [
7
{
8
"title": "Welcome to the root-level Activity"
9
}
10
]
11
},
12
{
13
"activities": [
14
{
15
"title": "Learn about paper"
16
},
17
{
18
"title": "Environmental friendliness"
19
},
20
{
21
"title": "Climate change"
22
}
23
]
24
},
25
{
26
"activities": [
27
{
28
"title": "Introduction to sales"
29
},
30
{
31
"title": "CRM technology"
32
},
33
{
34
"title": "Funnel configuration"
35
}
36
]
37
}
38
]
39
}
40
}
41
}
Copied!

Inline fragments

Using specific activity fragments act as a way to upcast objects. Here's an example of PeerReview ran against the connection above, and via direct activity lookup.
Query (Connection)
Response
Query (Direct lookup)
Response
1
{
2
course(id: "00000000-5945-95c6-65fc-a9747b200320") {
3
flows {
4
activities {
5
__typename
6
... on ActivityInterface {
7
title
8
}
9
... on PeerReviewActivity {
10
reviews {
11
edges {
12
node {
13
reviewType
14
createdAt
15
}
16
}
17
}
18
}
19
}
20
}
21
}
22
}
Copied!
Notice the specialized fields only return for the activity type that are PeerReviews:
1
{
2
"data": {
3
"course": {
4
"flows": [
5
{
6
"activities": [
7
{
8
"__typename": "ContentActivity",
9
"title": "Welcome aboard!"
10
}
11
]
12
},
13
{
14
"activities": [
15
{
16
"__typename": "ContentActivity",
17
"title": "Our Mission"
18
},
19
{
20
"__typename": "SubmissionActivity",
21
"title": "Make an impact"
22
},
23
{
24
"__typename": "PeerReviewActivity",
25
"title": "Spot-check and team build",
26
"reviews": {
27
"edges": [
28
{
29
"node": {
30
"reviewType": "PeerReview",
31
"createdAt": "2021-02-08T17:56:30.576582"
32
}
33
},
34
{
35
"node": {
36
"reviewType": "PeerReview",
37
"createdAt": "2021-02-08T17:56:30.617394"
38
}
39
},
40
{
41
"node": {
42
"reviewType": "PeerReview",
43
"createdAt": "2021-02-08T17:56:30.661450"
44
}
45
},
46
{
47
"node": {
48
"reviewType": "PeerReview",
49
"createdAt": "2021-02-08T17:56:30.703841"
50
}
51
},
52
{
53
"node": {
54
"reviewType": "PeerReview",
55
"createdAt": "2021-02-08T17:56:32.501897"
56
}
57
}
58
]
59
}
60
},
61
{
62
"__typename": "FeedbackReflectionActivity",
63
"title": "Introspect and reflect"
64
},
65
{
66
"__typename": "TeacherReviewActivity",
67
"title": "From your manager"
68
},
69
{
70
"__typename": "SelfReviewActivity",
71
"title": "How would you improve?"
72
},
73
{
74
"__typename": "ContentActivity",
75
"title": "Water cooler"
76
},
77
{
78
"__typename": "ContentActivity",
79
"title": "Networking: Meet across divisions"
80
}
81
]
82
},
83
{
84
"activities": [
85
{
86
"__typename": "ContentActivity",
87
"title": "Paper: Relevant today?"
88
},
89
{
90
"__typename": "SubmissionActivity",
91
"title": "How do you use paper?"
92
},
93
{
94
"__typename": "ContentActivity",
95
"title": "Our philosophy"
96
}
97
]
98
}
99
]
100
}
101
}
102
}
Copied!
title exists in PeerReviewActivity as well, no need to use ActivityInterface:
1
{
2
activity(id: "10aa7684-f0b2-4595-9161-4845e3602312") {
3
... on PeerReviewActivity {
4
title
5
reviews {
6
edges {
7
node {
8
reviewType
9
createdAt
10
}
11
}
12
}
13
}
14
}
15
}
Copied!
title exists on PeerReviewActivity, as it inherits from ActivityInterface
1
{
2
"data": {
3
"activity": {
4
"title": "Spot-check and team build",
5
"reviews": {
6
"edges": [
7
{
8
"node": {
9
"reviewType": "PeerReview",
10
"createdAt": "2021-02-08T17:56:30.576582"
11
}
12
},
13
{
14
"node": {
15
"reviewType": "PeerReview",
16
"createdAt": "2021-02-08T17:56:30.617394"
17
}
18
},
19
{
20
"node": {
21
"reviewType": "PeerReview",
22
"createdAt": "2021-02-08T17:56:30.661450"
23
}
24
},
25
{
26
"node": {
27
"reviewType": "PeerReview",
28
"createdAt": "2021-02-08T17:56:30.703841"
29
}
30
},
31
{
32
"node": {
33
"reviewType": "PeerReview",
34
"createdAt": "2021-02-08T17:56:32.501897"
35
}
36
}
37
]
38
}
39
}
40
}
41
}
Copied!

See also

Last modified 8mo ago