반응형
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).
반응형
'프론트엔드' 카테고리의 다른 글
6. GraphQL Mutations (0) | 2019.12.26 |
---|---|
5. GraphQL Interface (0) | 2019.12.26 |
3. GraphQL Fragments (0) | 2019.12.26 |
2. GraphQL Query (0) | 2019.12.26 |
1. What is GraphQL (0) | 2019.12.26 |