Skip to content

Commit

Permalink
Mutation Documentation Refinements (ChilliCream#4558)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib authored Dec 14, 2021
1 parent f048c8d commit 014b2e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ services
})
```

> Note: You can also partially opt-out of the convention by for instance crafting your own input type but letting the convention produce the payload.
## Errors

The second part of this new mutation convention involves user errors. We did a lot of work investigating how we should enable errors or even what pattern we should follow.
Expand Down
13 changes: 11 additions & 2 deletions website/src/docs/hotchocolate/defining-a-schema/mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ type UpdateUserNamePayload {

Following this pattern helps to keep the schema evolvable but requires a lot of boilerplate code to realize.

## Introduction
## Input and Payload

HotChocolate has built-in conventions for mutations to minimize boilerplate code.

Expand Down Expand Up @@ -349,7 +349,7 @@ type Mutation {
</ExampleTabs.Schema>
</ExampleTabs>

## Defining Errors
## Errors

The mutation conventions also allow you to create mutations that follow the error
[stage 6a Pattern Marc-Andre Giroux layed out](https://xuorig.medium.com/a-guide-to-graphql-errors-bb9ba9f15f85) with minimal effort.
Expand Down Expand Up @@ -958,6 +958,15 @@ public UpdateUserNamePayload UpdateUserNameAsync(UpdateUserNameInput input)
}
```

You can also partially opt-out:

```csharp
public User UpdateUserNameAsync(UpdateUserNameInput input)
{
//...
}
```

### Custom error interface

Lastly, we can customize the error interface we want to use with our mutation convention. The error interface is shared across all error types that the schema defines and provides the minimum shape that all errors have to fulfill.
Expand Down

0 comments on commit 014b2e2

Please sign in to comment.