Skip to content

Commit

Permalink
Update docs & CHANGELOG after #795
Browse files Browse the repository at this point in the history
  • Loading branch information
obmarg committed Jan 9, 2024
1 parent 8570b21 commit d0ce239
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html

## Unreleased - xxxx-xx-xx

### New Features

- `Enum`s can now opt out of exhaustiveness checking with the `non_exhaustive`
attribute

## v3.3.3 - 2024-01-09

### Bug Fixes
Expand Down
12 changes: 12 additions & 0 deletions cynic-book/src/derives/enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ smoothly, Cynic matches rust variants up to their equivalent
specifying a `rename_all = "None"` attribute, or customised alternative
`rename_all` values or individual `rename` attributes on the variants.

#### Exhaustiveness Checking

By default, cynic checks the exhuastiveness of `Enum`s - you should provide a
variant for each enum value in the GraphQL schema. You can also provide a `fallback` variant to provide forwards compatability - if the server adds new enum values they'll be caught by this variant.

You can opt-out of this exhaustiveness using the `#[cynic(non_exhaustive)]`
attribute. When this is present exhaustiveness is not checked, and the
fallback variant is used for all the variants missing from the selection.

#### Enum Attributes

An Enum can be configured with several attributes on the enum itself:
Expand All @@ -42,6 +51,9 @@ An Enum can be configured with several attributes on the enum itself:
- `schema_module` tells cynic where to find your schema module. This is
optional and should only be needed if your schema module is not in scope or
is named something other than `schema`.
- `non_exhaustive` can be provided to mark an enum as non-exhaustive. Such
enums are required to have a fallback variant, but not required to have
a variant for each value in the schema.

<!-- TODO: list of the rename rules, possibly pulled from codegen docs -->

Expand Down

0 comments on commit d0ce239

Please sign in to comment.