Modify individual keys in the JSON response - GraphQL

A short post - inspired from today I learn channel in my current company. Hope you guys enjoy it.

You can use GraphQL Aliases to modify individual keys in the JSON response.

If this is your original query

1
2
3
4
5
6
query {
listUsers {
id
name
}
}

you can introduce a GraphQL alias userName for the field name like so:

1
2
3
4
5
6
query {
listUsers {
id
userName: name
}
}