Skip to content

Commit

Permalink
Add documentation on void functions in the Mutation section of the …
Browse files Browse the repository at this point in the history
…documentation
  • Loading branch information
paulo-raca committed Feb 16, 2022
1 parent 3399916 commit eac3770
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/general/mutations.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,25 @@ example we might want to return an error if the book already exists.
You can checkout our documentation on
[dealing with errors](/docs/guides/errors#expected-errors) to learn how to return a
union of types from a mutation.

## Mutations without returned data

It is also possible to write a mutation that doesn't return anything.

This is mapped to a `Void` GraphQL scalar, and always returns `null`

```python+schema
@strawberry.type
class Mutation:
@strawberry.mutation
def restart() -> None:
print(f'Restarting the server')
---
type Mutation {
restart: Void
}
```

<Note>
Mutations with void-result go against [GQL best practices](https://graphql-rules.com/rules/mutation-payload)
</Note>

0 comments on commit eac3770

Please sign in to comment.