From 20df66f8f011d838d94034caa93278edd1e302de Mon Sep 17 00:00:00 2001 From: Magnus Hallin Date: Mon, 27 Feb 2017 21:15:13 +0100 Subject: [PATCH] Add fields to improve tooling compatibility This adds some non-standard/deprecated fields to better work with tools such as GraphiQL or GraphQLViz. --- src/schema/schema.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/schema/schema.rs b/src/schema/schema.rs index ad81cb62..748be235 100644 --- a/src/schema/schema.rs +++ b/src/schema/schema.rs @@ -44,6 +44,11 @@ graphql_object!(<'a> SchemaType<'a>: SchemaType<'a> as "__Schema" |&self| { self.mutation_type() } + // Included for compatibility with the introspection query in GraphQL.js + field subscription_type() -> Option { + None + } + field directives() -> Vec<&DirectiveType> { self.directive_list() } @@ -239,6 +244,26 @@ graphql_object!(<'a> DirectiveType<'a>: SchemaType<'a> as "__Directive" |&self| field args() -> &Vec { &self.arguments } + + // Included for compatibility with the introspection query in GraphQL.js + field deprecated "Use the locations array instead" + on_operation() -> bool { + self.locations.contains(&DirectiveLocation::Query) + } + + // Included for compatibility with the introspection query in GraphQL.js + field deprecated "Use the locations array instead" + on_fragment() -> bool { + self.locations.contains(&DirectiveLocation::FragmentDefinition) || + self.locations.contains(&DirectiveLocation::InlineFragment) || + self.locations.contains(&DirectiveLocation::FragmentSpread) + } + + // Included for compatibility with the introspection query in GraphQL.js + field deprecated "Use the locations array instead" + on_field() -> bool { + self.locations.contains(&DirectiveLocation::Field) + } }); graphql_enum!(DirectiveLocation as "__DirectiveLocation" {