@@ -53,6 +53,7 @@ Older version may or may not be compatible.
53
53
You can get started with ` apollo-compiler ` :
54
54
``` rust
55
55
use apollo_compiler :: Schema ;
56
+ use apollo_compiler :: validation :: ValidationOptions ;
56
57
57
58
let input = r # "
58
59
interface Pet {
@@ -87,14 +88,15 @@ let schema = Schema::parse(input, "document.graphql");
87
88
88
89
/// In case of validation errors, the panic message will be nicely formatted
89
90
/// to point at relevant parts of the source file(s)
90
- schema . validate (). unwrap ();
91
+ schema . validate (ValidationOptions :: default () ). unwrap ();
91
92
```
92
93
93
94
### Examples
94
95
#### Accessing fragment definition field types
95
96
96
97
``` rust
97
98
use apollo_compiler :: {Schema , ExecutableDocument , Node , executable};
99
+ use apollo_compiler :: validation :: ValidationOptions ;
98
100
99
101
fn main () {
100
102
let schema_input = r # "
@@ -124,8 +126,8 @@ fn main() {
124
126
let schema = Schema :: parse (schema_input , " schema.graphql" );
125
127
let document = ExecutableDocument :: parse (& schema , query_input , " query.graphql" );
126
128
127
- schema . validate (). unwrap ();
128
- document . validate (& schema ). unwrap ();
129
+ schema . validate (ValidationOptions :: default () ). unwrap ();
130
+ document . validate (& schema , ValidationOptions :: default () ). unwrap ();
129
131
130
132
let op = document . get_operation (Some (" getUser" )). expect (" getUser query does not exist" );
131
133
let fragment_in_op = op . selection_set. selections. iter (). filter_map (| sel | match sel {
@@ -149,6 +151,7 @@ fn main() {
149
151
#### Get a directive defined on a field used in a query operation definition.
150
152
``` rust
151
153
use apollo_compiler :: {Schema , ExecutableDocument , Node , executable};
154
+ use apollo_compiler :: validation :: ValidationOptions ;
152
155
153
156
fn main () {
154
157
let schema_input = r # "
@@ -187,8 +190,8 @@ fn main() {
187
190
let schema = Schema :: parse (schema_input , " schema.graphql" );
188
191
let document = ExecutableDocument :: parse (& schema , query_input , " query.graphql" );
189
192
190
- schema . validate (). unwrap ();
191
- document . validate (& schema ). unwrap ();
193
+ schema . validate (ValidationOptions :: default () ). unwrap ();
194
+ document . validate (& schema , ValidationOptions :: default () ). unwrap ();
192
195
193
196
let get_product_op = document
194
197
. get_operation (Some (" getProduct" ))
@@ -215,6 +218,8 @@ fn main() {
215
218
216
219
#### Printing diagnostics for a faulty GraphQL document
217
220
``` rust
221
+ use apollo_compiler :: validation :: ValidationOptions ;
222
+
218
223
let input = r # "
219
224
query {
220
225
cat {
@@ -273,10 +278,10 @@ union CatOrDog = Cat | Dog
273
278
274
279
let (schema , executable ) = apollo_compiler :: parse_mixed (input , " document.graphql" );
275
280
276
- if let Err (diagnostics ) = schema . validate () {
281
+ if let Err (diagnostics ) = schema . validate (ValidationOptions :: default () ) {
277
282
println! (" {diagnostics}" )
278
283
}
279
- if let Err (diagnostics ) = executable . validate (& schema ) {
284
+ if let Err (diagnostics ) = executable . validate (& schema , ValidationOptions :: default () ) {
280
285
println! (" {diagnostics}" )
281
286
}
282
287
```
0 commit comments