Skip to content

Commit

Permalink
Added documentation for aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
mcop1 committed Nov 4, 2024
1 parent 80e9f50 commit 4488fb8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/10_GraphQL/04_Query/06_Operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Operators allow to modify and transform the data before it is delivered to the e

#### Alias

Simply gives the child node a different name.
Simply gives the child node a different name.
See also [Using Aliases](./11_Using_Aliases.md) for more information on how to use aliases.

#### Date Formatter

Expand Down
37 changes: 37 additions & 0 deletions doc/10_GraphQL/04_Query/11_Using_Aliases.md
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
}
}
}
```


0 comments on commit 4488fb8

Please sign in to comment.