4. GRAPHQL UNION
If you want to return different types on different queries, you can use **union**.
```
union AgendaItem = StudyGroup | Workout
```
```
query schedule {
agneda {
...on Workout {
name
reps
}
...on StudyGroup {
name
subject
students
}
}
}
```
```
...on Workout
```
is an inline fragment with the name "Workout"
you can also use named fragments (from previous post).
```
union AgendaItem = StudyGroup | Workout
```
```
query schedule {
agneda {
...on Workout {
name
reps
}
...on StudyGroup {
name
subject
students
}
}
}
```
```
...on Workout
```
is an inline fragment with the name "Workout"
you can also use named fragments (from previous post).
댓글
댓글 쓰기