Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Task] Add documentation for aliases #908

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}
}
```


Loading