Skip to content
This repository was archived by the owner on Mar 20, 2024. It is now read-only.

Commit ec23915

Browse files
committed
Document skipping fields
Part of #8.
1 parent b2d1c76 commit ec23915

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

docs/types/objects/defining_objects.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ struct Person {
5050
```
5151

5252
Objects and fields without doc comments can instead set a `description`
53-
in the `graphql` attribute. The following example is equivalent to the above:
53+
via the `graphql` attribute. The following example is equivalent to the above:
5454

5555
!FILENAME GraphQL descriptions via attribute
5656

@@ -186,5 +186,24 @@ struct Person {
186186
```
187187

188188
The `name`, `description`, and `deprecation` arguments can of course be
189-
combined. Some restrictions from the GraphQL spec stil applies though; you can
189+
combined. Some restrictions from the GraphQL spec still applies though; you can
190190
only deprecate object fields and enum values.
191+
192+
## Skipping fields
193+
194+
By default all fields in a `GraphQLObject` are included in the generated GraphQL type. To prevent including a specific field, annotate the field with `#[graphql(skip)]`:
195+
196+
```rust
197+
# extern crate juniper;
198+
# #[macro_use] extern crate juniper_codegen;
199+
#
200+
#[derive(GraphQLObject)]
201+
struct Person {
202+
name: String,
203+
age: i32,
204+
#[graphql(skip)]
205+
password_hash: String, // This cannot be queried or modified from GraphQL
206+
}
207+
208+
# fn main() {}
209+
```

0 commit comments

Comments
 (0)