From c5993ca88fdf091b0e78f0e01fa07250c2c1afa7 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Thu, 1 Feb 2018 14:56:31 -0500 Subject: [PATCH] Fix printing object type definitions Directives come after the implemented interfaces. See https://github.com/graphql/graphql-js/blob/360fa06e43fed32b63fba99b353515e7b56eee20/src/language/printer.js#L117-L129 for the canonical printer. --- lib/graphql/language/printer.rb | 2 +- spec/graphql/language/printer_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/graphql/language/printer.rb b/lib/graphql/language/printer.rb index 3601cb5338..ec98542a36 100644 --- a/lib/graphql/language/printer.rb +++ b/lib/graphql/language/printer.rb @@ -154,8 +154,8 @@ def print_scalar_type_definition(scalar_type) def print_object_type_definition(object_type) out = print_description(object_type) out << "type #{object_type.name}" - out << print_directives(object_type.directives) out << " implements " << object_type.interfaces.map(&:name).join(", ") unless object_type.interfaces.empty? + out << print_directives(object_type.directives) out << print_field_definitions(object_type.fields) end diff --git a/spec/graphql/language/printer_spec.rb b/spec/graphql/language/printer_spec.rb index 3f457e41b1..3fe5a29b92 100644 --- a/spec/graphql/language/printer_spec.rb +++ b/spec/graphql/language/printer_spec.rb @@ -105,7 +105,7 @@ end describe "full featured schema" do - # From: https://github.com/graphql/graphql-js/blob/bc96406ab44453a120da25a0bd6e2b0237119ddf/src/language/__tests__/schema-kitchen-sink.graphql + # Based on: https://github.com/graphql/graphql-js/blob/bc96406ab44453a120da25a0bd6e2b0237119ddf/src/language/__tests__/schema-kitchen-sink.graphql let(:query_string) {<<-schema schema { query: QueryType @@ -128,7 +128,7 @@ # Scalar description scalar CustomScalar - type AnnotatedObject @onObject(arg: "value") { + type AnnotatedObject implements Bar @onObject(arg: "value") { annotatedField(arg: Type = "default" @onArg): Type @onField }