Say I have this GraphQL query:
query GetUser($user_id: Int) {
user(user_id: $user_id) {
name
}
groups(user_id $user_id) {
name
}
}
This query recieves user id, and returns:
- user’s name
- names of all the groups this user belongs to
I know that user
should be defined in the SDL like this:
type Query{
user(user_id: Int): User
}
and that the server should define a resolver function named user
.
But – can I be sure that groups
field is defined the same way?
More specifically – can I se sure that referring groups
in a query is possible, i.e. like this:
query Groups($user_id: Int) {
groups(user_id: $user_id) {
name
}
}
Thanks
New contributor