mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-16 19:40:39 +03:00
Initial page creation.
parent
d339007c92
commit
9de6e9ee28
37
Aliasing-(rename-query-elements).md
Normal file
37
Aliasing-(rename-query-elements).md
Normal file
|
@ -0,0 +1,37 @@
|
|||
GraphQL allows you to `alias`, or rename, elements of your queries. This is built-in and trivial, but a powerful feature that is often overlooked.
|
||||
|
||||
To alias, simply prefix the elements you wish to rename with the desired string followed by `:`, like so:
|
||||
|
||||
```
|
||||
{
|
||||
imaginarium:places(
|
||||
id:"UGxhY2VUeXBlOjUxOA==, UGxhY2VUeXBlOjU0Nw==")
|
||||
{
|
||||
menagerie:edges {
|
||||
dogs:node {
|
||||
dogtag:id
|
||||
place:name
|
||||
favoritePizzaPlace:name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
Which results in:
|
||||
```
|
||||
{
|
||||
"data": {
|
||||
"imaginarium": {
|
||||
"menagerie": [
|
||||
{
|
||||
"dogs": {
|
||||
"dogtag": "UGxhY2VUeXBlOjUxOA==",
|
||||
"place": "Dallas, Dallas, Texas, United States",
|
||||
"favoritePizzaPlace": "Dallas, Dallas, Texas, United States"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user