Skip to content

Commit 20df66f

Browse files
committed
Add fields to improve tooling compatibility
This adds some non-standard/deprecated fields to better work with tools such as GraphiQL or GraphQLViz.
1 parent eca20cd commit 20df66f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/schema/schema.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ graphql_object!(<'a> SchemaType<'a>: SchemaType<'a> as "__Schema" |&self| {
4444
self.mutation_type()
4545
}
4646

47+
// Included for compatibility with the introspection query in GraphQL.js
48+
field subscription_type() -> Option<TypeType> {
49+
None
50+
}
51+
4752
field directives() -> Vec<&DirectiveType> {
4853
self.directive_list()
4954
}
@@ -239,6 +244,26 @@ graphql_object!(<'a> DirectiveType<'a>: SchemaType<'a> as "__Directive" |&self|
239244
field args() -> &Vec<Argument> {
240245
&self.arguments
241246
}
247+
248+
// Included for compatibility with the introspection query in GraphQL.js
249+
field deprecated "Use the locations array instead"
250+
on_operation() -> bool {
251+
self.locations.contains(&DirectiveLocation::Query)
252+
}
253+
254+
// Included for compatibility with the introspection query in GraphQL.js
255+
field deprecated "Use the locations array instead"
256+
on_fragment() -> bool {
257+
self.locations.contains(&DirectiveLocation::FragmentDefinition) ||
258+
self.locations.contains(&DirectiveLocation::InlineFragment) ||
259+
self.locations.contains(&DirectiveLocation::FragmentSpread)
260+
}
261+
262+
// Included for compatibility with the introspection query in GraphQL.js
263+
field deprecated "Use the locations array instead"
264+
on_field() -> bool {
265+
self.locations.contains(&DirectiveLocation::Field)
266+
}
242267
});
243268

244269
graphql_enum!(DirectiveLocation as "__DirectiveLocation" {

0 commit comments

Comments
 (0)