-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Using Aliases | ||
|
||
Aliases are used to rename the result of a field. | ||
This is useful when you want to return multiple fields with the same name. | ||
|
||
There are two ways to use aliases: | ||
|
||
## Alias Operator | ||
|
||
See [06_Operators.md](06_Operators.md) for more information. | ||
|
||
## Alias in the Query | ||
|
||
Get a `Car` with id 82 and return the number of doors. | ||
The first value is the alias, the second value is the field name. | ||
|
||
#### Request | ||
```graphql | ||
{ | ||
getCar(id: 82) { | ||
doors: numberOfDoors | ||
} | ||
} | ||
``` | ||
|
||
#### Response | ||
```json | ||
{ | ||
"data": { | ||
"getCar": { | ||
"doors": 2 | ||
} | ||
} | ||
} | ||
``` | ||
|
||
|