From ae8b48a8fa8c3f1cce82d39c5d27a716560754ef Mon Sep 17 00:00:00 2001 From: Evan Huus Date: Tue, 11 May 2021 19:22:48 +0000 Subject: [PATCH] Add failing test for directives with input cycles It was noted in a comment in build_from_definition.rb that this might be a problem. It is a problem (this test currently fails with SystemStackError). --- .../schema/build_from_definition_spec.rb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spec/graphql/schema/build_from_definition_spec.rb b/spec/graphql/schema/build_from_definition_spec.rb index a02ece8dd3..9c805b11d0 100644 --- a/spec/graphql/schema/build_from_definition_spec.rb +++ b/spec/graphql/schema/build_from_definition_spec.rb @@ -122,6 +122,32 @@ def assert_schema_and_compare_output(definition) assert_schema_and_compare_output(schema.chop) end + it 'can build a schema with directives whose inputs have a cycle' do + schema = <<-SCHEMA +schema { + query: Hello +} + +directive @foo(arg: InputA) on FIELD + +input InputA { + value: InputB +} + +input InputB { + value: InputA +} + SCHEMA + + parsed_schema = GraphQL::Schema.from_definition(schema) + assert_equal ["deprecated", "foo", "include", "skip"], parsed_schema.directives.keys.sort + parsed_schema.directives.values.each do |dir_class| + assert dir_class < GraphQL::Schema::Directive + end + + assert_schema_and_compare_output(schema.chop) + end + it 'supports descriptions and definition_line' do schema = <<-SCHEMA schema {