graphql 1.7.14 → 1.8.0.pre1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/generators/graphql/function_generator.rb +1 -1
- data/lib/generators/graphql/loader_generator.rb +1 -1
- data/lib/generators/graphql/mutation_generator.rb +1 -6
- data/lib/generators/graphql/templates/function.erb +2 -2
- data/lib/generators/graphql/templates/loader.erb +2 -2
- data/lib/graphql.rb +2 -0
- data/lib/graphql/argument.rb +0 -1
- data/lib/graphql/backwards_compatibility.rb +2 -3
- data/lib/graphql/base_type.rb +18 -16
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -117
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -14
- data/lib/graphql/define/assign_object_field.rb +5 -12
- data/lib/graphql/deprecated_dsl.rb +28 -0
- data/lib/graphql/directive.rb +0 -1
- data/lib/graphql/enum_type.rb +1 -3
- data/lib/graphql/execution.rb +0 -1
- data/lib/graphql/execution/multiplex.rb +29 -12
- data/lib/graphql/field.rb +5 -20
- data/lib/graphql/function.rb +12 -0
- data/lib/graphql/input_object_type.rb +1 -3
- data/lib/graphql/internal_representation/node.rb +14 -26
- data/lib/graphql/internal_representation/visit.rb +6 -3
- data/lib/graphql/introspection/arguments_field.rb +0 -1
- data/lib/graphql/introspection/enum_values_field.rb +0 -1
- data/lib/graphql/introspection/fields_field.rb +0 -1
- data/lib/graphql/introspection/input_fields_field.rb +0 -1
- data/lib/graphql/introspection/interfaces_field.rb +0 -1
- data/lib/graphql/introspection/of_type_field.rb +0 -1
- data/lib/graphql/introspection/possible_types_field.rb +0 -1
- data/lib/graphql/introspection/schema_field.rb +0 -1
- data/lib/graphql/introspection/type_by_name_field.rb +0 -1
- data/lib/graphql/introspection/typename_field.rb +0 -1
- data/lib/graphql/language.rb +0 -3
- data/lib/graphql/language/generation.rb +182 -3
- data/lib/graphql/language/lexer.rb +69 -144
- data/lib/graphql/language/lexer.rl +4 -15
- data/lib/graphql/language/nodes.rb +76 -136
- data/lib/graphql/language/parser.rb +621 -668
- data/lib/graphql/language/parser.y +11 -17
- data/lib/graphql/language/token.rb +3 -10
- data/lib/graphql/object_type.rb +6 -1
- data/lib/graphql/query.rb +13 -8
- data/lib/graphql/query/arguments.rb +33 -48
- data/lib/graphql/query/context.rb +1 -0
- data/lib/graphql/query/literal_input.rb +1 -4
- data/lib/graphql/relay/connection_resolve.rb +3 -0
- data/lib/graphql/relay/global_id_resolve.rb +5 -1
- data/lib/graphql/relay/relation_connection.rb +19 -14
- data/lib/graphql/schema.rb +219 -12
- data/lib/graphql/schema/argument.rb +33 -0
- data/lib/graphql/schema/build_from_definition.rb +18 -64
- data/lib/graphql/schema/enum.rb +76 -0
- data/lib/graphql/schema/field.rb +127 -0
- data/lib/graphql/schema/field/dynamic_resolve.rb +63 -0
- data/lib/graphql/schema/field/unwrapped_resolve.rb +20 -0
- data/lib/graphql/schema/input_object.rb +61 -0
- data/lib/graphql/schema/interface.rb +32 -0
- data/lib/graphql/schema/loader.rb +2 -2
- data/lib/graphql/schema/member.rb +97 -0
- data/lib/graphql/schema/member/build_type.rb +106 -0
- data/lib/graphql/schema/member/has_fields.rb +56 -0
- data/lib/graphql/schema/member/instrumentation.rb +113 -0
- data/lib/graphql/schema/member/list_type_proxy.rb +21 -0
- data/lib/graphql/schema/member/non_null_type_proxy.rb +21 -0
- data/lib/graphql/schema/object.rb +65 -0
- data/lib/graphql/schema/printer.rb +266 -33
- data/lib/graphql/schema/scalar.rb +25 -0
- data/lib/graphql/schema/traversal.rb +26 -17
- data/lib/graphql/schema/union.rb +48 -0
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -5
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +8 -15
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +1 -11
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +5 -7
- data/lib/graphql/tracing.rb +0 -1
- data/lib/graphql/tracing/platform_tracing.rb +7 -20
- data/lib/graphql/tracing/scout_tracing.rb +2 -2
- data/lib/graphql/unresolved_type_error.rb +2 -3
- data/lib/graphql/version.rb +1 -1
- data/readme.md +1 -1
- data/spec/dummy/app/channels/graphql_channel.rb +1 -22
- data/spec/dummy/log/development.log +0 -239
- data/spec/dummy/log/test.log +0 -204
- data/spec/dummy/test/system/action_cable_subscription_test.rb +0 -4
- data/spec/dummy/tmp/screenshots/failures_test_it_handles_subscriptions.png +0 -0
- data/spec/generators/graphql/function_generator_spec.rb +0 -26
- data/spec/generators/graphql/loader_generator_spec.rb +0 -24
- data/spec/graphql/analysis/max_query_complexity_spec.rb +3 -3
- data/spec/graphql/analysis/max_query_depth_spec.rb +3 -3
- data/spec/graphql/backtrace_spec.rb +0 -10
- data/spec/graphql/base_type_spec.rb +5 -19
- data/spec/graphql/boolean_type_spec.rb +3 -3
- data/spec/graphql/directive_spec.rb +1 -3
- data/spec/graphql/enum_type_spec.rb +5 -18
- data/spec/graphql/execution/execute_spec.rb +1 -1
- data/spec/graphql/execution/multiplex_spec.rb +2 -2
- data/spec/graphql/float_type_spec.rb +2 -2
- data/spec/graphql/id_type_spec.rb +1 -1
- data/spec/graphql/input_object_type_spec.rb +2 -15
- data/spec/graphql/int_type_spec.rb +2 -2
- data/spec/graphql/internal_representation/rewrite_spec.rb +2 -2
- data/spec/graphql/introspection/schema_type_spec.rb +0 -1
- data/spec/graphql/language/generation_spec.rb +186 -21
- data/spec/graphql/language/lexer_spec.rb +1 -21
- data/spec/graphql/language/nodes_spec.rb +12 -21
- data/spec/graphql/language/parser_spec.rb +1 -1
- data/spec/graphql/query/arguments_spec.rb +15 -37
- data/spec/graphql/query/serial_execution/value_resolution_spec.rb +2 -2
- data/spec/graphql/query/variables_spec.rb +1 -1
- data/spec/graphql/query_spec.rb +5 -31
- data/spec/graphql/rake_task_spec.rb +1 -3
- data/spec/graphql/relay/base_connection_spec.rb +1 -1
- data/spec/graphql/relay/connection_instrumentation_spec.rb +2 -2
- data/spec/graphql/relay/connection_resolve_spec.rb +1 -1
- data/spec/graphql/relay/connection_type_spec.rb +1 -1
- data/spec/graphql/relay/mutation_spec.rb +3 -3
- data/spec/graphql/relay/relation_connection_spec.rb +1 -65
- data/spec/graphql/schema/build_from_definition_spec.rb +4 -86
- data/spec/graphql/schema/enum_spec.rb +60 -0
- data/spec/graphql/schema/field_spec.rb +14 -0
- data/spec/graphql/schema/input_object_spec.rb +43 -0
- data/spec/graphql/schema/interface_spec.rb +98 -0
- data/spec/graphql/schema/object_spec.rb +119 -0
- data/spec/graphql/schema/printer_spec.rb +15 -92
- data/spec/graphql/schema/scalar_spec.rb +40 -0
- data/spec/graphql/schema/union_spec.rb +35 -0
- data/spec/graphql/schema/validation_spec.rb +1 -1
- data/spec/graphql/schema/warden_spec.rb +11 -11
- data/spec/graphql/schema_spec.rb +25 -23
- data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +2 -10
- data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +2 -2
- data/spec/graphql/string_type_spec.rb +3 -3
- data/spec/graphql/subscriptions_spec.rb +1 -1
- data/spec/graphql/tracing/platform_tracing_spec.rb +1 -60
- data/spec/support/dummy/schema.rb +25 -39
- data/spec/support/jazz.rb +334 -0
- data/spec/support/lazy_helpers.rb +21 -23
- data/spec/support/star_wars/data.rb +7 -6
- data/spec/support/star_wars/schema.rb +109 -142
- metadata +39 -33
- data/lib/graphql/execution/instrumentation.rb +0 -82
- data/lib/graphql/language/block_string.rb +0 -47
- data/lib/graphql/language/document_from_schema_definition.rb +0 -277
- data/lib/graphql/language/printer.rb +0 -351
- data/lib/graphql/tracing/data_dog_tracing.rb +0 -49
- data/spec/graphql/execution/instrumentation_spec.rb +0 -165
- data/spec/graphql/language/block_string_spec.rb +0 -70
- data/spec/graphql/language/document_from_schema_definition_spec.rb +0 -770
- data/spec/graphql/language/printer_spec.rb +0 -203
| @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            require "spec_helper"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe GraphQL::Schema::Field do
         | 
| 5 | 
            +
              describe "graphql definition" do
         | 
| 6 | 
            +
                let(:object_class) { Jazz::Query }
         | 
| 7 | 
            +
                let(:field) { object_class.fields.find { |f| f.name == "find" } }
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                it "uses the argument class" do
         | 
| 10 | 
            +
                  arg_defn = field.graphql_definition.arguments.values.first
         | 
| 11 | 
            +
                  assert_equal :ok, arg_defn.metadata[:custom]
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
            end
         | 
| @@ -0,0 +1,43 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            require "spec_helper"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe GraphQL::Schema::InputObject do
         | 
| 5 | 
            +
              let(:input_object) { Jazz::EnsembleInput }
         | 
| 6 | 
            +
              describe "type info" do
         | 
| 7 | 
            +
                it "has it" do
         | 
| 8 | 
            +
                  assert_equal "EnsembleInput", input_object.graphql_name
         | 
| 9 | 
            +
                  assert_equal nil, input_object.description
         | 
| 10 | 
            +
                  assert_equal 1, input_object.arguments.size
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              describe ".to_graphql" do
         | 
| 15 | 
            +
                it "assigns itself as the arguments_class" do
         | 
| 16 | 
            +
                  assert_equal input_object, input_object.to_graphql.arguments_class
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              describe "in queries" do
         | 
| 21 | 
            +
                it "is passed to the field method" do
         | 
| 22 | 
            +
                  query_str = <<-GRAPHQL
         | 
| 23 | 
            +
                  {
         | 
| 24 | 
            +
                    inspectInput(input: {
         | 
| 25 | 
            +
                      stringValue: "ABC",
         | 
| 26 | 
            +
                      legacyInput: { intValue: 4 },
         | 
| 27 | 
            +
                      nestedInput: { stringValue: "xyz"}
         | 
| 28 | 
            +
                    })
         | 
| 29 | 
            +
                  }
         | 
| 30 | 
            +
                  GRAPHQL
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  res = Jazz::Schema.execute(query_str, context: { message: "hi" })
         | 
| 33 | 
            +
                  expected_info = [
         | 
| 34 | 
            +
                    "Jazz::InspectableInput",
         | 
| 35 | 
            +
                    "hi, ABC, 4, (hi, xyz, -, (-))",
         | 
| 36 | 
            +
                    "ABC",
         | 
| 37 | 
            +
                    "ABC",
         | 
| 38 | 
            +
                    "ABC",
         | 
| 39 | 
            +
                  ]
         | 
| 40 | 
            +
                  assert_equal expected_info, res["data"]["inspectInput"]
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
            end
         | 
| @@ -0,0 +1,98 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            require "spec_helper"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe GraphQL::Schema::Interface do
         | 
| 5 | 
            +
              let(:interface) { Jazz::GloballyIdentifiableType }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              describe "type info" do
         | 
| 8 | 
            +
                it "tells its type info" do
         | 
| 9 | 
            +
                  assert_equal "GloballyIdentifiable", interface.graphql_name
         | 
| 10 | 
            +
                  assert_equal 2, interface.fields.size
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                class NewInterface1 < Jazz::GloballyIdentifiableType
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                class NewInterface2 < Jazz::GloballyIdentifiableType
         | 
| 17 | 
            +
                  module Implementation
         | 
| 18 | 
            +
                    def new_method
         | 
| 19 | 
            +
                    end
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                it "can override Implementation" do
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  new_object_1 = Class.new(GraphQL::Schema::Object) do
         | 
| 26 | 
            +
                    implements NewInterface1
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  assert_equal 2, new_object_1.fields.size
         | 
| 30 | 
            +
                  assert new_object_1.method_defined?(:id)
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  new_object_2 = Class.new(GraphQL::Schema::Object) do
         | 
| 33 | 
            +
                    implements NewInterface2
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  assert_equal 2, new_object_2.fields.size
         | 
| 37 | 
            +
                  # It got the new method
         | 
| 38 | 
            +
                  assert new_object_2.method_defined?(:new_method)
         | 
| 39 | 
            +
                  # But not the old method
         | 
| 40 | 
            +
                  refute new_object_2.method_defined?(:id)
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
              end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
              describe ".to_graphql" do
         | 
| 45 | 
            +
                it "creates an InterfaceType" do
         | 
| 46 | 
            +
                  interface_type = interface.to_graphql
         | 
| 47 | 
            +
                  assert_equal "GloballyIdentifiable", interface_type.name
         | 
| 48 | 
            +
                  field = interface_type.all_fields.first
         | 
| 49 | 
            +
                  assert_equal "id", field.name
         | 
| 50 | 
            +
                  assert_equal GraphQL::ID_TYPE.to_non_null_type, field.type
         | 
| 51 | 
            +
                  assert_equal "A unique identifier for this object", field.description
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              describe "in queries" do
         | 
| 56 | 
            +
                it "works" do
         | 
| 57 | 
            +
                  query_str = <<-GRAPHQL
         | 
| 58 | 
            +
                  {
         | 
| 59 | 
            +
                    piano: find(id: "Instrument/Piano") {
         | 
| 60 | 
            +
                      id
         | 
| 61 | 
            +
                      upcasedId
         | 
| 62 | 
            +
                      ... on Instrument {
         | 
| 63 | 
            +
                        family
         | 
| 64 | 
            +
                      }
         | 
| 65 | 
            +
                    }
         | 
| 66 | 
            +
                  }
         | 
| 67 | 
            +
                  GRAPHQL
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  res = Jazz::Schema.execute(query_str)
         | 
| 70 | 
            +
                  expected_piano = {
         | 
| 71 | 
            +
                    "id" => "Instrument/Piano",
         | 
| 72 | 
            +
                    "upcasedId" => "INSTRUMENT/PIANO",
         | 
| 73 | 
            +
                    "family" => "KEYS",
         | 
| 74 | 
            +
                  }
         | 
| 75 | 
            +
                  assert_equal(expected_piano, res["data"]["piano"])
         | 
| 76 | 
            +
                end
         | 
| 77 | 
            +
             | 
| 78 | 
            +
                it "applies custom field attributes" do
         | 
| 79 | 
            +
                  query_str = <<-GRAPHQL
         | 
| 80 | 
            +
                  {
         | 
| 81 | 
            +
                    find(id: "Ensemble/Bela Fleck and the Flecktones") {
         | 
| 82 | 
            +
                      upcasedId
         | 
| 83 | 
            +
                      ... on Ensemble {
         | 
| 84 | 
            +
                        name
         | 
| 85 | 
            +
                      }
         | 
| 86 | 
            +
                    }
         | 
| 87 | 
            +
                  }
         | 
| 88 | 
            +
                  GRAPHQL
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                  res = Jazz::Schema.execute(query_str)
         | 
| 91 | 
            +
                  expected_data = {
         | 
| 92 | 
            +
                    "upcasedId" => "ENSEMBLE/BELA FLECK AND THE FLECKTONES",
         | 
| 93 | 
            +
                    "name" => "Bela Fleck and the Flecktones"
         | 
| 94 | 
            +
                  }
         | 
| 95 | 
            +
                  assert_equal(expected_data, res["data"]["find"])
         | 
| 96 | 
            +
                end
         | 
| 97 | 
            +
              end
         | 
| 98 | 
            +
            end
         | 
| @@ -0,0 +1,119 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
            require "spec_helper"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe GraphQL::Schema::Object do
         | 
| 5 | 
            +
              describe "class attributes" do
         | 
| 6 | 
            +
                let(:object_class) { Jazz::Ensemble }
         | 
| 7 | 
            +
                it "tells type data" do
         | 
| 8 | 
            +
                  assert_equal "Ensemble", object_class.graphql_name
         | 
| 9 | 
            +
                  assert_equal "A group of musicians playing together", object_class.description
         | 
| 10 | 
            +
                  assert_equal 5, object_class.fields.size
         | 
| 11 | 
            +
                  assert_equal 2, object_class.interfaces.size
         | 
| 12 | 
            +
                  # Compatibility methods are delegated to the underlying BaseType
         | 
| 13 | 
            +
                  assert object_class.respond_to?(:connection_type)
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                it "inherits fields and interfaces" do
         | 
| 17 | 
            +
                  new_object_class = Class.new(object_class) do
         | 
| 18 | 
            +
                    field :newField, String, null: true
         | 
| 19 | 
            +
                    field :name, String, "The new description", null: true
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                  # one more than the parent class
         | 
| 23 | 
            +
                  assert_equal 6, new_object_class.fields.size
         | 
| 24 | 
            +
                  # inherited interfaces are present
         | 
| 25 | 
            +
                  assert_equal 2, new_object_class.interfaces.size
         | 
| 26 | 
            +
                  # The new field is present
         | 
| 27 | 
            +
                  assert new_object_class.fields.find { |f| f.name == "newField" }
         | 
| 28 | 
            +
                  # The overridden field is present:
         | 
| 29 | 
            +
                  name_field = new_object_class.fields.find { |f| f.name == "name" }
         | 
| 30 | 
            +
                  assert_equal "The new description", name_field.description
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              describe ".to_graphql_type" do
         | 
| 35 | 
            +
                let(:obj_type) { Jazz::Ensemble.to_graphql }
         | 
| 36 | 
            +
                it "returns a matching GraphQL::ObjectType" do
         | 
| 37 | 
            +
                  assert_equal "Ensemble", obj_type.name
         | 
| 38 | 
            +
                  assert_equal "A group of musicians playing together", obj_type.description
         | 
| 39 | 
            +
                  assert_equal 5, obj_type.all_fields.size
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  name_field = obj_type.all_fields[2]
         | 
| 42 | 
            +
                  assert_equal "name", name_field.name
         | 
| 43 | 
            +
                  assert_equal GraphQL::STRING_TYPE.to_non_null_type, name_field.type
         | 
| 44 | 
            +
                  assert_equal nil, name_field.description
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                it "has a custom implementation" do
         | 
| 48 | 
            +
                  assert_equal obj_type.metadata[:config], :configged
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                it "uses the custom field class" do
         | 
| 52 | 
            +
                  query_str = <<-GRAPHQL
         | 
| 53 | 
            +
                  {
         | 
| 54 | 
            +
                    ensembles { upcaseName }
         | 
| 55 | 
            +
                  }
         | 
| 56 | 
            +
                  GRAPHQL
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  res = Jazz::Schema.execute(query_str)
         | 
| 59 | 
            +
                  assert_equal ["BELA FLECK AND THE FLECKTONES"], res["data"]["ensembles"].map { |e| e["upcaseName"] }
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
              end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
             | 
| 64 | 
            +
              describe "in queries" do
         | 
| 65 | 
            +
                after {
         | 
| 66 | 
            +
                  Jazz::Models.reset
         | 
| 67 | 
            +
                }
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                it "returns data" do
         | 
| 70 | 
            +
                  query_str = <<-GRAPHQL
         | 
| 71 | 
            +
                  {
         | 
| 72 | 
            +
                    ensembles { name }
         | 
| 73 | 
            +
                    instruments { name }
         | 
| 74 | 
            +
                  }
         | 
| 75 | 
            +
                  GRAPHQL
         | 
| 76 | 
            +
                  res = Jazz::Schema.execute(query_str)
         | 
| 77 | 
            +
                  assert_equal [{"name" => "Bela Fleck and the Flecktones"}], res["data"]["ensembles"]
         | 
| 78 | 
            +
                  assert_equal({"name" => "Banjo"}, res["data"]["instruments"].first)
         | 
| 79 | 
            +
                end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
                it "does mutations" do
         | 
| 82 | 
            +
                  mutation_str = <<-GRAPHQL
         | 
| 83 | 
            +
                  mutation AddEnsemble($name: String!) {
         | 
| 84 | 
            +
                    addEnsemble(input: { name: $name }) {
         | 
| 85 | 
            +
                      id
         | 
| 86 | 
            +
                    }
         | 
| 87 | 
            +
                  }
         | 
| 88 | 
            +
                  GRAPHQL
         | 
| 89 | 
            +
             | 
| 90 | 
            +
                  query_str = <<-GRAPHQL
         | 
| 91 | 
            +
                  query($id: ID!) {
         | 
| 92 | 
            +
                    find(id: $id) {
         | 
| 93 | 
            +
                      ... on Ensemble {
         | 
| 94 | 
            +
                        name
         | 
| 95 | 
            +
                      }
         | 
| 96 | 
            +
                    }
         | 
| 97 | 
            +
                  }
         | 
| 98 | 
            +
                  GRAPHQL
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                  res = Jazz::Schema.execute(mutation_str, variables: { "name" => "Miles Davis Quartet" })
         | 
| 101 | 
            +
                  new_id = res["data"]["addEnsemble"]["id"]
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                  res2 = Jazz::Schema.execute(query_str, variables: { "id" => new_id })
         | 
| 104 | 
            +
                  assert_equal "Miles Davis Quartet", res2["data"]["find"]["name"]
         | 
| 105 | 
            +
                end
         | 
| 106 | 
            +
             | 
| 107 | 
            +
                it "initializes root wrappers once" do
         | 
| 108 | 
            +
                  query_str = " { oid1: objectId oid2: objectId }"
         | 
| 109 | 
            +
                  res = Jazz::Schema.execute(query_str)
         | 
| 110 | 
            +
                  assert_equal res["data"]["oid1"], res["data"]["oid2"]
         | 
| 111 | 
            +
                end
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                it "skips fields properly" do
         | 
| 114 | 
            +
                  query_str = "{ find(id: \"MagicalSkipId\") { __typename } }"
         | 
| 115 | 
            +
                  res = Jazz::Schema.execute(query_str)
         | 
| 116 | 
            +
                  assert_equal({"data" => nil }, res.to_h)
         | 
| 117 | 
            +
                end
         | 
| 118 | 
            +
              end
         | 
| 119 | 
            +
            end
         | 
| @@ -14,11 +14,7 @@ describe GraphQL::Schema::Printer do | |
| 14 14 |  | 
| 15 15 | 
             
                  value "FOO", value: :foo
         | 
| 16 16 | 
             
                  value "BAR", value: :bar
         | 
| 17 | 
            -
                  value "BAZ", deprecation_reason:  | 
| 18 | 
            -
            Use "BAR" instead.
         | 
| 19 | 
            -
             | 
| 20 | 
            -
            It's the replacement for this value.
         | 
| 21 | 
            -
            REASON
         | 
| 17 | 
            +
                  value "BAZ", deprecation_reason: 'Use "BAR".'
         | 
| 22 18 | 
             
                  value "WOZ", deprecation_reason: GraphQL::Directive::DEFAULT_DEPRECATION_REASON
         | 
| 23 19 | 
             
                end
         | 
| 24 20 |  | 
| @@ -140,14 +136,6 @@ schema { | |
| 140 136 | 
             
              query: Root
         | 
| 141 137 | 
             
            }
         | 
| 142 138 |  | 
| 143 | 
            -
            # Marks an element of a GraphQL schema as no longer supported.
         | 
| 144 | 
            -
            directive @deprecated(
         | 
| 145 | 
            -
              # Explains why this element was deprecated, usually also including a suggestion
         | 
| 146 | 
            -
              # for how to access supported similar data. Formatted in
         | 
| 147 | 
            -
              # [Markdown](https://daringfireball.net/projects/markdown/).
         | 
| 148 | 
            -
              reason: String = "No longer supported"
         | 
| 149 | 
            -
            ) on FIELD_DEFINITION | ENUM_VALUE
         | 
| 150 | 
            -
             | 
| 151 139 | 
             
            # Directs the executor to include this field or fragment only when the `if` argument is true.
         | 
| 152 140 | 
             
            directive @include(
         | 
| 153 141 | 
             
              # Included when true.
         | 
| @@ -160,6 +148,14 @@ directive @skip( | |
| 160 148 | 
             
              if: Boolean!
         | 
| 161 149 | 
             
            ) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
         | 
| 162 150 |  | 
| 151 | 
            +
            # Marks an element of a GraphQL schema as no longer supported.
         | 
| 152 | 
            +
            directive @deprecated(
         | 
| 153 | 
            +
              # Explains why this element was deprecated, usually also including a suggestion
         | 
| 154 | 
            +
              # for how to access supported similar data. Formatted in
         | 
| 155 | 
            +
              # [Markdown](https://daringfireball.net/projects/markdown/).
         | 
| 156 | 
            +
              reason: String = "No longer supported"
         | 
| 157 | 
            +
            ) on FIELD_DEFINITION | ENUM_VALUE
         | 
| 158 | 
            +
             | 
| 163 159 | 
             
            # A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
         | 
| 164 160 | 
             
            #
         | 
| 165 161 | 
             
            # In some cases, you need to provide options to alter GraphQL's execution behavior
         | 
| @@ -349,6 +345,7 @@ schema { | |
| 349 345 | 
             
              subscription: Subscription
         | 
| 350 346 | 
             
            }
         | 
| 351 347 | 
             
            SCHEMA
         | 
| 348 | 
            +
             | 
| 352 349 | 
             
                  assert_match expected, GraphQL::Schema::Printer.print_schema(custom_schema)
         | 
| 353 350 | 
             
                end
         | 
| 354 351 |  | 
| @@ -356,6 +353,7 @@ SCHEMA | |
| 356 353 | 
             
                  custom_mutation = schema.mutation.redefine(name: "MyMutationRoot")
         | 
| 357 354 | 
             
                  custom_schema = schema.redefine(mutation: custom_mutation)
         | 
| 358 355 |  | 
| 356 | 
            +
             | 
| 359 357 | 
             
                  expected = <<SCHEMA
         | 
| 360 358 | 
             
            schema {
         | 
| 361 359 | 
             
              query: Query
         | 
| @@ -392,7 +390,7 @@ type Audio { | |
| 392 390 |  | 
| 393 391 | 
             
            enum Choice {
         | 
| 394 392 | 
             
              BAR
         | 
| 395 | 
            -
              BAZ @deprecated(reason: "Use \\\"BAR\\\" | 
| 393 | 
            +
              BAZ @deprecated(reason: "Use \\\"BAR\\\".")
         | 
| 396 394 | 
             
              FOO
         | 
| 397 395 | 
             
              WOZ @deprecated
         | 
| 398 396 | 
             
            }
         | 
| @@ -491,6 +489,7 @@ enum Choice { | |
| 491 489 | 
             
            }
         | 
| 492 490 |  | 
| 493 491 | 
             
            type Subscription {
         | 
| 492 | 
            +
             | 
| 494 493 | 
             
            }
         | 
| 495 494 |  | 
| 496 495 | 
             
            input Varied {
         | 
| @@ -510,9 +509,7 @@ SCHEMA | |
| 510 509 | 
             
                  when GraphQL::Argument
         | 
| 511 510 | 
             
                    member.name != "id"
         | 
| 512 511 | 
             
                  else
         | 
| 513 | 
            -
                     | 
| 514 | 
            -
                      member.deprecation_reason.nil?
         | 
| 515 | 
            -
                    end
         | 
| 512 | 
            +
                    member.deprecation_reason.nil?
         | 
| 516 513 | 
             
                  end
         | 
| 517 514 | 
             
                }
         | 
| 518 515 |  | 
| @@ -603,86 +600,12 @@ SCHEMA | |
| 603 600 | 
             
            type Post {
         | 
| 604 601 | 
             
              body: String!
         | 
| 605 602 | 
             
              comments: [Comment!]
         | 
| 606 | 
            -
              comments_count: Int! @deprecated(reason: "Use \\\"comments\\\" | 
| 603 | 
            +
              comments_count: Int! @deprecated(reason: \"Use \\\"comments\\\".\")
         | 
| 607 604 | 
             
              id: ID!
         | 
| 608 605 | 
             
              title: String!
         | 
| 609 606 | 
             
            }
         | 
| 610 607 | 
             
            SCHEMA
         | 
| 611 608 | 
             
                  assert_equal expected.chomp, GraphQL::Schema::Printer.new(schema).print_type(schema.types['Post'])
         | 
| 612 609 | 
             
                end
         | 
| 613 | 
            -
             | 
| 614 | 
            -
                it "can print arguments that use non-standard Ruby objects as default values" do
         | 
| 615 | 
            -
                  backing_object = Struct.new(:value)
         | 
| 616 | 
            -
             | 
| 617 | 
            -
                  scalar_type = GraphQL::ScalarType.define do
         | 
| 618 | 
            -
                    name "SomeType"
         | 
| 619 | 
            -
                    coerce_input ->(value, ctx) { backing_object.new(value) }
         | 
| 620 | 
            -
                    coerce_result ->(obj, ctx) { obj.value }
         | 
| 621 | 
            -
                  end
         | 
| 622 | 
            -
             | 
| 623 | 
            -
                  query_root = GraphQL::ObjectType.define do
         | 
| 624 | 
            -
                    name "Query"
         | 
| 625 | 
            -
                    description "The query root of this schema"
         | 
| 626 | 
            -
             | 
| 627 | 
            -
                    field :example do
         | 
| 628 | 
            -
                      type scalar_type
         | 
| 629 | 
            -
                      argument :input, scalar_type, default_value: backing_object.new("Howdy")
         | 
| 630 | 
            -
                      resolve ->(obj, args, ctx) { args[:input] }
         | 
| 631 | 
            -
                    end
         | 
| 632 | 
            -
                  end
         | 
| 633 | 
            -
             | 
| 634 | 
            -
                  schema = GraphQL::Schema.define do
         | 
| 635 | 
            -
                    query query_root
         | 
| 636 | 
            -
                  end
         | 
| 637 | 
            -
             | 
| 638 | 
            -
                  expected = <<SCHEMA
         | 
| 639 | 
            -
            # The query root of this schema
         | 
| 640 | 
            -
            type Query {
         | 
| 641 | 
            -
              example(input: SomeType = "Howdy"): SomeType
         | 
| 642 | 
            -
            }
         | 
| 643 | 
            -
            SCHEMA
         | 
| 644 | 
            -
             | 
| 645 | 
            -
                  assert_equal expected.chomp, GraphQL::Schema::Printer.new(schema).print_type(query_root)
         | 
| 646 | 
            -
                end
         | 
| 647 | 
            -
              end
         | 
| 648 | 
            -
             | 
| 649 | 
            -
              describe "#print_directive" do
         | 
| 650 | 
            -
                it "prints the deprecation reason in a single line escaped string including line breaks" do
         | 
| 651 | 
            -
                  expected = <<SCHEMA
         | 
| 652 | 
            -
            enum Choice {
         | 
| 653 | 
            -
              BAR
         | 
| 654 | 
            -
              BAZ @deprecated(reason: "Use \\\"BAR\\\" instead.\\n\\nIt's the replacement for this value.\\n")
         | 
| 655 | 
            -
              FOO
         | 
| 656 | 
            -
              WOZ @deprecated
         | 
| 657 | 
            -
            }
         | 
| 658 | 
            -
             | 
| 659 | 
            -
            type Subscription {
         | 
| 660 | 
            -
            }
         | 
| 661 | 
            -
             | 
| 662 | 
            -
            input Varied {
         | 
| 663 | 
            -
              bool: Boolean
         | 
| 664 | 
            -
              enum: Choice = FOO
         | 
| 665 | 
            -
              float: Float
         | 
| 666 | 
            -
              int: Int
         | 
| 667 | 
            -
            }
         | 
| 668 | 
            -
            SCHEMA
         | 
| 669 | 
            -
             | 
| 670 | 
            -
                  only_filter = ->(member, ctx) {
         | 
| 671 | 
            -
                    case member
         | 
| 672 | 
            -
                    when GraphQL::ScalarType
         | 
| 673 | 
            -
                      true
         | 
| 674 | 
            -
                    when GraphQL::BaseType
         | 
| 675 | 
            -
                      ctx[:names].include?(member.name)
         | 
| 676 | 
            -
                    when GraphQL::Argument
         | 
| 677 | 
            -
                      member.name != "id"
         | 
| 678 | 
            -
                    else
         | 
| 679 | 
            -
                      true
         | 
| 680 | 
            -
                    end
         | 
| 681 | 
            -
                  }
         | 
| 682 | 
            -
             | 
| 683 | 
            -
                  context = { names: ["Varied", "Choice", "Subscription"] }
         | 
| 684 | 
            -
             | 
| 685 | 
            -
                  assert_equal expected.chomp, GraphQL::Schema::Printer.new(schema, context: context, only: only_filter).print_schema
         | 
| 686 | 
            -
                end
         | 
| 687 610 | 
             
              end
         | 
| 688 611 | 
             
            end
         |