graphql 1.7.6 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/graphql/function_generator.rb +1 -1
- data/lib/generators/graphql/install_generator.rb +14 -8
- data/lib/generators/graphql/loader_generator.rb +1 -1
- data/lib/generators/graphql/mutation_generator.rb +6 -1
- data/lib/generators/graphql/templates/function.erb +2 -2
- data/lib/generators/graphql/templates/loader.erb +2 -2
- data/lib/generators/graphql/templates/schema.erb +1 -1
- data/lib/graphql/argument.rb +25 -19
- data/lib/graphql/backtrace/tracer.rb +16 -22
- data/lib/graphql/backtrace.rb +1 -1
- data/lib/graphql/backwards_compatibility.rb +2 -3
- data/lib/graphql/base_type.rb +31 -31
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +14 -0
- data/lib/graphql/compatibility/query_parser_specification.rb +117 -0
- data/lib/graphql/define/assign_object_field.rb +5 -12
- data/lib/graphql/deprecated_dsl.rb +42 -0
- data/lib/graphql/directive.rb +1 -0
- data/lib/graphql/enum_type.rb +3 -1
- data/lib/graphql/execution/execute.rb +21 -13
- data/lib/graphql/execution/instrumentation.rb +82 -0
- data/lib/graphql/execution/lazy/lazy_method_map.rb +1 -1
- data/lib/graphql/execution/lazy/resolve.rb +1 -3
- data/lib/graphql/execution/multiplex.rb +12 -29
- data/lib/graphql/execution.rb +1 -0
- data/lib/graphql/field.rb +21 -4
- data/lib/graphql/function.rb +14 -0
- data/lib/graphql/input_object_type.rb +3 -1
- data/lib/graphql/interface_type.rb +5 -3
- data/lib/graphql/internal_representation/node.rb +26 -14
- data/lib/graphql/internal_representation/visit.rb +3 -6
- data/lib/graphql/introspection/base_object.rb +16 -0
- data/lib/graphql/introspection/directive_location_enum.rb +11 -7
- data/lib/graphql/introspection/directive_type.rb +23 -16
- data/lib/graphql/introspection/dynamic_fields.rb +11 -0
- data/lib/graphql/introspection/entry_points.rb +29 -0
- data/lib/graphql/introspection/enum_value_type.rb +16 -11
- data/lib/graphql/introspection/field_type.rb +21 -12
- data/lib/graphql/introspection/input_value_type.rb +26 -23
- data/lib/graphql/introspection/schema_field.rb +7 -2
- data/lib/graphql/introspection/schema_type.rb +36 -22
- data/lib/graphql/introspection/type_by_name_field.rb +10 -2
- data/lib/graphql/introspection/type_kind_enum.rb +10 -6
- data/lib/graphql/introspection/type_type.rb +85 -23
- data/lib/graphql/introspection/typename_field.rb +1 -0
- data/lib/graphql/introspection.rb +3 -10
- data/lib/graphql/language/block_string.rb +47 -0
- data/lib/graphql/language/document_from_schema_definition.rb +280 -0
- data/lib/graphql/language/generation.rb +3 -182
- data/lib/graphql/language/lexer.rb +144 -69
- data/lib/graphql/language/lexer.rl +15 -4
- data/lib/graphql/language/nodes.rb +141 -78
- data/lib/graphql/language/parser.rb +677 -630
- data/lib/graphql/language/parser.y +18 -12
- data/lib/graphql/language/printer.rb +361 -0
- data/lib/graphql/language/token.rb +10 -3
- data/lib/graphql/language.rb +3 -0
- data/lib/graphql/non_null_type.rb +1 -1
- data/lib/graphql/object_type.rb +1 -6
- data/lib/graphql/query/arguments.rb +63 -32
- data/lib/graphql/query/context.rb +32 -2
- data/lib/graphql/query/literal_input.rb +4 -1
- data/lib/graphql/query/null_context.rb +1 -1
- data/lib/graphql/query/result.rb +1 -1
- data/lib/graphql/query/variables.rb +21 -3
- data/lib/graphql/query.rb +19 -6
- data/lib/graphql/railtie.rb +109 -0
- data/lib/graphql/relay/connection_resolve.rb +3 -0
- data/lib/graphql/relay/connection_type.rb +5 -3
- data/lib/graphql/relay/edge_type.rb +2 -1
- data/lib/graphql/relay/global_id_resolve.rb +5 -1
- data/lib/graphql/relay/mongo_relation_connection.rb +40 -0
- data/lib/graphql/relay/mutation/instrumentation.rb +1 -1
- data/lib/graphql/relay/mutation/resolve.rb +5 -1
- data/lib/graphql/relay/relation_connection.rb +14 -19
- data/lib/graphql/relay/type_extensions.rb +30 -0
- data/lib/graphql/relay.rb +2 -0
- data/lib/graphql/scalar_type.rb +14 -2
- data/lib/graphql/schema/argument.rb +92 -0
- data/lib/graphql/schema/build_from_definition.rb +64 -18
- data/lib/graphql/schema/enum.rb +85 -0
- data/lib/graphql/schema/enum_value.rb +74 -0
- data/lib/graphql/schema/field.rb +372 -0
- data/lib/graphql/schema/finder.rb +153 -0
- data/lib/graphql/schema/input_object.rb +87 -0
- data/lib/graphql/schema/interface.rb +105 -0
- data/lib/graphql/schema/introspection_system.rb +93 -0
- data/lib/graphql/schema/late_bound_type.rb +32 -0
- data/lib/graphql/schema/list.rb +32 -0
- data/lib/graphql/schema/loader.rb +2 -2
- data/lib/graphql/schema/member/accepts_definition.rb +152 -0
- data/lib/graphql/schema/member/base_dsl_methods.rb +100 -0
- data/lib/graphql/schema/member/build_type.rb +137 -0
- data/lib/graphql/schema/member/cached_graphql_definition.rb +26 -0
- data/lib/graphql/schema/member/graphql_type_names.rb +21 -0
- data/lib/graphql/schema/member/has_arguments.rb +50 -0
- data/lib/graphql/schema/member/has_fields.rb +130 -0
- data/lib/graphql/schema/member/instrumentation.rb +115 -0
- data/lib/graphql/schema/member/type_system_helpers.rb +34 -0
- data/lib/graphql/schema/member.rb +28 -0
- data/lib/graphql/schema/middleware_chain.rb +5 -1
- data/lib/graphql/schema/mutation.rb +138 -0
- data/lib/graphql/schema/non_null.rb +38 -0
- data/lib/graphql/schema/object.rb +81 -0
- data/lib/graphql/schema/printer.rb +33 -266
- data/lib/graphql/schema/relay_classic_mutation.rb +87 -0
- data/lib/graphql/schema/rescue_middleware.rb +8 -7
- data/lib/graphql/schema/resolver.rb +122 -0
- data/lib/graphql/schema/scalar.rb +35 -0
- data/lib/graphql/schema/traversal.rb +102 -22
- data/lib/graphql/schema/union.rb +36 -0
- data/lib/graphql/schema/validation.rb +3 -2
- data/lib/graphql/schema.rb +381 -12
- data/lib/graphql/static_validation/definition_dependencies.rb +1 -1
- data/lib/graphql/static_validation/literal_validator.rb +16 -4
- data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +6 -6
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +5 -1
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +15 -8
- data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +11 -1
- data/lib/graphql/static_validation/validation_context.rb +1 -1
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +7 -5
- data/lib/graphql/subscriptions/instrumentation.rb +5 -1
- data/lib/graphql/subscriptions/serialize.rb +2 -0
- data/lib/graphql/subscriptions.rb +90 -16
- data/lib/graphql/tracing/data_dog_tracing.rb +49 -0
- data/lib/graphql/tracing/new_relic_tracing.rb +26 -0
- data/lib/graphql/tracing/platform_tracing.rb +20 -7
- data/lib/graphql/tracing/scout_tracing.rb +2 -2
- data/lib/graphql/tracing.rb +1 -0
- data/lib/graphql/unresolved_type_error.rb +3 -2
- data/lib/graphql/upgrader/member.rb +894 -0
- data/lib/graphql/upgrader/schema.rb +37 -0
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +5 -25
- data/readme.md +2 -2
- data/spec/dummy/app/channels/graphql_channel.rb +23 -2
- data/spec/dummy/log/development.log +239 -0
- data/spec/dummy/log/test.log +410 -0
- data/spec/dummy/test/system/action_cable_subscription_test.rb +4 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-x/-xYZjAnuuzgR79fcznLTQtSdh6AARxu8FcQ_J6p7L3U.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/13/13HiV12xyoQvT-1L39ZzLwMZxjyaGMiENmfw7f-QTIc.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/3W/3Wtf5pCWdqq0AB-iB0Y9uUNrTkruRxIEf1XFn_BETU0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5i/5iguGafb4hOn8262Kn8Q37ogNN9MxxQKGKNzHAzUcvI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8m/8mj2T6yy847Mc2Z7k3Xzh8O91hhVJt3NrPe8ASNDlIA.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DT/DTQyMpr4ABZYQetsdRJ5A7S4jf1r3ie4FGOR7GZBNSs.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Dq/DqJ5_yJPrP5iLlOQyTQsjAVI5FE5LCVDkED0f7GgsSo.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/F8/F8MUNRzORGFgr329fNM0xLaoWCXdv3BIalT7dsvLfjs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/KB/KB07ZaKNC5uXJ7TjLi-WqnY6g7dq8wWp_8N3HNjBNxg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Rw/RwDuCV-XpnCtjNkvhpJfBuxXMk0b5AD3L9eR6M-wcy0.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/UL/ULdjhhb0bRuqmaG7XSZlFYzGYCXTDnqZuJBTWRlzqgw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Up/UpPNgh0yYoUsyMDh5zWqe_U6qJIyTC6-dxMMAs1vvlM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Wg/Wguh-szFGTI1gaL6npYwPekMXflugRei7F_mOyRucXg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/X-/X-khLYMA9mqFRPg3zAi86mREDxpKl4bdKYp3uF6WHos.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bi/BIkdhfxsezxM4q-HZ4oCNTq97WEJTigcq0tpX2cDvbY.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ff/FfxmA4CMHQZT7exx0G7NS1Wpcnny0vzp-Jhc2H36bp8.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gE/gEiiG4GZNy_djEjK2pHm_NgA-gyhLZhdQvo0Yt96GqE.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/gn/gnA9ZSqpjccNL2m8pe_jBvY6SinXlCzXDWyop83Od8s.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/lO/lOAan3cMwCE_Hli6gsDML88xFNfn0nxPmvrSkW7eEOw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m1/M1pv8MJEPLXGLvS8QxVh3DSO9cI4mRt5FHFWdrvUj6o.cache +2 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/m7/m77qH7ZqH0_0SmwJbiKGDd-aLau1Dav847DC6ge46zY.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/sj/sjRjnjRB37lH2vrgtkdJ8Cz84__IJ978IuKTM7HcztI.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/um/um1JrirR4hJhK-1rE-HywlyCi5ibgxHVrReiujZBWJM.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/v4/v4fwVytD7ITcE0_GDbslZEYud8a5Okm85fV1o7SDl6g.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/v_/v_0PAQt0iipQjFP5zjgkkk9Stnpf4VzvnMv67d1Keuw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wd/wdT9U4MKxe1PyqNjVuCKMpCl3dxGCIRJIlwUTfh2DQU.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xI/xIaxut_fEIhKBDqljTNwYaADK9kj3gG0ESrfHs-5_og.cache +3 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/y0/y0SJOqIx2fn1SKqOkAihsQow0trRJrSIyAswufVuoA8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zg/zgpzeaX-KZErHyGJ1aBH3ZusweNXMneVZule88XsIJI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zy/zYFltDy-8VC-uKq2BVEiJJyYXNFvVzAKuMlR3ZIYZsk.cache +0 -0
- data/spec/dummy/tmp/screenshots/failures_test_it_handles_subscriptions.png +0 -0
- data/spec/fixtures/upgrader/account.original.rb +19 -0
- data/spec/fixtures/upgrader/account.transformed.rb +20 -0
- data/spec/fixtures/upgrader/blame_range.original.rb +43 -0
- data/spec/fixtures/upgrader/blame_range.transformed.rb +30 -0
- data/spec/fixtures/upgrader/date_time.original.rb +24 -0
- data/spec/fixtures/upgrader/date_time.transformed.rb +23 -0
- data/spec/fixtures/upgrader/delete_project.original.rb +28 -0
- data/spec/fixtures/upgrader/delete_project.transformed.rb +27 -0
- data/spec/fixtures/upgrader/gist_order_field.original.rb +14 -0
- data/spec/fixtures/upgrader/gist_order_field.transformed.rb +13 -0
- data/spec/fixtures/upgrader/increment_count.original.rb +59 -0
- data/spec/fixtures/upgrader/increment_count.transformed.rb +50 -0
- data/spec/fixtures/upgrader/photo.original.rb +10 -0
- data/spec/fixtures/upgrader/photo.transformed.rb +12 -0
- data/spec/fixtures/upgrader/release_order.original.rb +15 -0
- data/spec/fixtures/upgrader/release_order.transformed.rb +14 -0
- data/spec/fixtures/upgrader/starrable.original.rb +49 -0
- data/spec/fixtures/upgrader/starrable.transformed.rb +46 -0
- data/spec/fixtures/upgrader/subscribable.original.rb +55 -0
- data/spec/fixtures/upgrader/subscribable.transformed.rb +51 -0
- data/spec/fixtures/upgrader/type_x.original.rb +65 -0
- data/spec/fixtures/upgrader/type_x.transformed.rb +56 -0
- data/spec/generators/graphql/function_generator_spec.rb +26 -0
- data/spec/generators/graphql/install_generator_spec.rb +1 -1
- data/spec/generators/graphql/loader_generator_spec.rb +24 -0
- 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/argument_spec.rb +21 -0
- data/spec/graphql/backtrace_spec.rb +10 -0
- data/spec/graphql/base_type_spec.rb +42 -0
- data/spec/graphql/boolean_type_spec.rb +3 -3
- data/spec/graphql/directive_spec.rb +3 -1
- data/spec/graphql/enum_type_spec.rb +18 -5
- data/spec/graphql/execution/execute_spec.rb +4 -4
- data/spec/graphql/execution/instrumentation_spec.rb +165 -0
- data/spec/graphql/execution/multiplex_spec.rb +2 -2
- data/spec/graphql/execution_error_spec.rb +18 -0
- 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 +15 -2
- data/spec/graphql/int_type_spec.rb +2 -2
- data/spec/graphql/interface_type_spec.rb +12 -0
- data/spec/graphql/internal_representation/rewrite_spec.rb +2 -2
- data/spec/graphql/introspection/schema_type_spec.rb +2 -0
- data/spec/graphql/language/block_string_spec.rb +70 -0
- data/spec/graphql/language/document_from_schema_definition_spec.rb +770 -0
- data/spec/graphql/language/generation_spec.rb +21 -186
- data/spec/graphql/language/lexer_spec.rb +21 -1
- data/spec/graphql/language/nodes_spec.rb +21 -12
- data/spec/graphql/language/parser_spec.rb +1 -1
- data/spec/graphql/language/printer_spec.rb +203 -0
- data/spec/graphql/object_type_spec.rb +22 -0
- data/spec/graphql/query/arguments_spec.rb +25 -15
- data/spec/graphql/query/context_spec.rb +18 -0
- data/spec/graphql/query/executor_spec.rb +2 -1
- data/spec/graphql/query/serial_execution/value_resolution_spec.rb +2 -8
- data/spec/graphql/query/variables_spec.rb +42 -1
- data/spec/graphql/query_spec.rb +31 -5
- data/spec/graphql/rake_task_spec.rb +3 -1
- 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/mongo_relation_connection_spec.rb +474 -0
- data/spec/graphql/relay/mutation_spec.rb +9 -7
- data/spec/graphql/relay/range_add_spec.rb +5 -1
- data/spec/graphql/relay/relation_connection_spec.rb +65 -1
- data/spec/graphql/schema/argument_spec.rb +87 -0
- data/spec/graphql/schema/build_from_definition_spec.rb +89 -5
- data/spec/graphql/schema/enum_spec.rb +74 -0
- data/spec/graphql/schema/field_spec.rb +225 -0
- data/spec/graphql/schema/finder_spec.rb +135 -0
- data/spec/graphql/schema/input_object_spec.rb +111 -0
- data/spec/graphql/schema/instrumentation_spec.rb +40 -0
- data/spec/graphql/schema/interface_spec.rb +185 -0
- data/spec/graphql/schema/introspection_system_spec.rb +39 -0
- data/spec/graphql/schema/member/accepts_definition_spec.rb +111 -0
- data/spec/graphql/schema/member/build_type_spec.rb +17 -0
- data/spec/graphql/schema/member/has_fields_spec.rb +129 -0
- data/spec/graphql/schema/member/type_system_helpers_spec.rb +63 -0
- data/spec/graphql/schema/mutation_spec.rb +148 -0
- data/spec/graphql/schema/object_spec.rb +175 -0
- data/spec/graphql/schema/printer_spec.rb +111 -15
- data/spec/graphql/schema/relay_classic_mutation_spec.rb +38 -0
- data/spec/graphql/schema/rescue_middleware_spec.rb +11 -0
- data/spec/graphql/schema/resolver_spec.rb +131 -0
- data/spec/graphql/schema/scalar_spec.rb +95 -0
- data/spec/graphql/schema/traversal_spec.rb +31 -0
- data/spec/graphql/schema/union_spec.rb +65 -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 +55 -12
- data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +10 -2
- 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 +273 -184
- data/spec/graphql/tracing/active_support_notifications_tracing_spec.rb +1 -1
- data/spec/graphql/tracing/new_relic_tracing_spec.rb +47 -0
- data/spec/graphql/tracing/platform_tracing_spec.rb +60 -1
- data/spec/graphql/union_type_spec.rb +1 -1
- data/spec/graphql/upgrader/member_spec.rb +516 -0
- data/spec/graphql/upgrader/schema_spec.rb +82 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/dummy/schema.rb +53 -24
- data/spec/support/jazz.rb +544 -0
- data/spec/support/lazy_helpers.rb +21 -23
- data/spec/support/new_relic.rb +24 -0
- data/spec/support/star_trek/data.rb +109 -0
- data/spec/support/star_trek/schema.rb +388 -0
- data/spec/support/star_wars/data.rb +6 -7
- data/spec/support/star_wars/schema.rb +127 -171
- metadata +233 -11
- data/lib/graphql/introspection/arguments_field.rb +0 -7
- data/lib/graphql/introspection/enum_values_field.rb +0 -18
- data/lib/graphql/introspection/fields_field.rb +0 -13
- data/lib/graphql/introspection/input_fields_field.rb +0 -12
- data/lib/graphql/introspection/interfaces_field.rb +0 -11
- data/lib/graphql/introspection/of_type_field.rb +0 -6
- data/lib/graphql/introspection/possible_types_field.rb +0 -11
@@ -14,7 +14,11 @@ describe GraphQL::Schema::Printer do
|
|
14
14
|
|
15
15
|
value "FOO", value: :foo
|
16
16
|
value "BAR", value: :bar
|
17
|
-
value "BAZ", deprecation_reason:
|
17
|
+
value "BAZ", deprecation_reason: <<-REASON
|
18
|
+
Use "BAR" instead.
|
19
|
+
|
20
|
+
It's the replacement for this value.
|
21
|
+
REASON
|
18
22
|
value "WOZ", deprecation_reason: GraphQL::Directive::DEFAULT_DEPRECATION_REASON
|
19
23
|
end
|
20
24
|
|
@@ -136,6 +140,14 @@ schema {
|
|
136
140
|
query: Root
|
137
141
|
}
|
138
142
|
|
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
|
+
|
139
151
|
# Directs the executor to include this field or fragment only when the `if` argument is true.
|
140
152
|
directive @include(
|
141
153
|
# Included when true.
|
@@ -148,14 +160,6 @@ directive @skip(
|
|
148
160
|
if: Boolean!
|
149
161
|
) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
|
150
162
|
|
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
|
-
|
159
163
|
# A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
|
160
164
|
#
|
161
165
|
# In some cases, you need to provide options to alter GraphQL's execution behavior
|
@@ -345,7 +349,6 @@ schema {
|
|
345
349
|
subscription: Subscription
|
346
350
|
}
|
347
351
|
SCHEMA
|
348
|
-
|
349
352
|
assert_match expected, GraphQL::Schema::Printer.print_schema(custom_schema)
|
350
353
|
end
|
351
354
|
|
@@ -353,7 +356,6 @@ SCHEMA
|
|
353
356
|
custom_mutation = schema.mutation.redefine(name: "MyMutationRoot")
|
354
357
|
custom_schema = schema.redefine(mutation: custom_mutation)
|
355
358
|
|
356
|
-
|
357
359
|
expected = <<SCHEMA
|
358
360
|
schema {
|
359
361
|
query: Query
|
@@ -390,7 +392,7 @@ type Audio {
|
|
390
392
|
|
391
393
|
enum Choice {
|
392
394
|
BAR
|
393
|
-
BAZ @deprecated(reason: "Use \\\"BAR\\\"
|
395
|
+
BAZ @deprecated(reason: "Use \\\"BAR\\\" instead.\\n\\nIt's the replacement for this value.\\n")
|
394
396
|
FOO
|
395
397
|
WOZ @deprecated
|
396
398
|
}
|
@@ -479,6 +481,25 @@ SCHEMA
|
|
479
481
|
|
480
482
|
assert_equal expected.chomp, GraphQL::Schema::Printer.print_schema(schema)
|
481
483
|
end
|
484
|
+
|
485
|
+
it 'prints a schema without directives' do
|
486
|
+
query_type = Class.new(GraphQL::Schema::Object) do
|
487
|
+
graphql_name 'Query'
|
488
|
+
|
489
|
+
field :foobar, Integer, null: false
|
490
|
+
|
491
|
+
def foobar
|
492
|
+
152
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
schema = Class.new(GraphQL::Schema) do
|
497
|
+
query query_type
|
498
|
+
end
|
499
|
+
|
500
|
+
expected = "type Query {\n foobar: Int!\n}"
|
501
|
+
assert_equal expected, GraphQL::Schema::Printer.new(schema).print_schema
|
502
|
+
end
|
482
503
|
end
|
483
504
|
|
484
505
|
it "applies an `only` filter" do
|
@@ -489,7 +510,6 @@ enum Choice {
|
|
489
510
|
}
|
490
511
|
|
491
512
|
type Subscription {
|
492
|
-
|
493
513
|
}
|
494
514
|
|
495
515
|
input Varied {
|
@@ -509,7 +529,9 @@ SCHEMA
|
|
509
529
|
when GraphQL::Argument
|
510
530
|
member.name != "id"
|
511
531
|
else
|
512
|
-
member.deprecation_reason
|
532
|
+
if member.respond_to?(:deprecation_reason)
|
533
|
+
member.deprecation_reason.nil?
|
534
|
+
end
|
513
535
|
end
|
514
536
|
}
|
515
537
|
|
@@ -600,12 +622,86 @@ SCHEMA
|
|
600
622
|
type Post {
|
601
623
|
body: String!
|
602
624
|
comments: [Comment!]
|
603
|
-
comments_count: Int! @deprecated(reason:
|
625
|
+
comments_count: Int! @deprecated(reason: "Use \\\"comments\\\".")
|
604
626
|
id: ID!
|
605
627
|
title: String!
|
606
628
|
}
|
607
629
|
SCHEMA
|
608
630
|
assert_equal expected.chomp, GraphQL::Schema::Printer.new(schema).print_type(schema.types['Post'])
|
609
631
|
end
|
632
|
+
|
633
|
+
it "can print arguments that use non-standard Ruby objects as default values" do
|
634
|
+
backing_object = Struct.new(:value)
|
635
|
+
|
636
|
+
scalar_type = GraphQL::ScalarType.define do
|
637
|
+
name "SomeType"
|
638
|
+
coerce_input ->(value, ctx) { backing_object.new(value) }
|
639
|
+
coerce_result ->(obj, ctx) { obj.value }
|
640
|
+
end
|
641
|
+
|
642
|
+
query_root = GraphQL::ObjectType.define do
|
643
|
+
name "Query"
|
644
|
+
description "The query root of this schema"
|
645
|
+
|
646
|
+
field :example do
|
647
|
+
type scalar_type
|
648
|
+
argument :input, scalar_type, default_value: backing_object.new("Howdy")
|
649
|
+
resolve ->(obj, args, ctx) { args[:input] }
|
650
|
+
end
|
651
|
+
end
|
652
|
+
|
653
|
+
schema = GraphQL::Schema.define do
|
654
|
+
query query_root
|
655
|
+
end
|
656
|
+
|
657
|
+
expected = <<SCHEMA
|
658
|
+
# The query root of this schema
|
659
|
+
type Query {
|
660
|
+
example(input: SomeType = "Howdy"): SomeType
|
661
|
+
}
|
662
|
+
SCHEMA
|
663
|
+
|
664
|
+
assert_equal expected.chomp, GraphQL::Schema::Printer.new(schema).print_type(query_root)
|
665
|
+
end
|
666
|
+
end
|
667
|
+
|
668
|
+
describe "#print_directive" do
|
669
|
+
it "prints the deprecation reason in a single line escaped string including line breaks" do
|
670
|
+
expected = <<SCHEMA
|
671
|
+
enum Choice {
|
672
|
+
BAR
|
673
|
+
BAZ @deprecated(reason: "Use \\\"BAR\\\" instead.\\n\\nIt's the replacement for this value.\\n")
|
674
|
+
FOO
|
675
|
+
WOZ @deprecated
|
676
|
+
}
|
677
|
+
|
678
|
+
type Subscription {
|
679
|
+
}
|
680
|
+
|
681
|
+
input Varied {
|
682
|
+
bool: Boolean
|
683
|
+
enum: Choice = FOO
|
684
|
+
float: Float
|
685
|
+
int: Int
|
686
|
+
}
|
687
|
+
SCHEMA
|
688
|
+
|
689
|
+
only_filter = ->(member, ctx) {
|
690
|
+
case member
|
691
|
+
when GraphQL::ScalarType
|
692
|
+
true
|
693
|
+
when GraphQL::BaseType
|
694
|
+
ctx[:names].include?(member.name)
|
695
|
+
when GraphQL::Argument
|
696
|
+
member.name != "id"
|
697
|
+
else
|
698
|
+
true
|
699
|
+
end
|
700
|
+
}
|
701
|
+
|
702
|
+
context = { names: ["Varied", "Choice", "Subscription"] }
|
703
|
+
|
704
|
+
assert_equal expected.chomp, GraphQL::Schema::Printer.new(schema, context: context, only: only_filter).print_schema
|
705
|
+
end
|
610
706
|
end
|
611
707
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe GraphQL::Schema::RelayClassicMutation do
|
5
|
+
describe ".input_object_class" do
|
6
|
+
it "is inherited, with a default" do
|
7
|
+
custom_input = Class.new(GraphQL::Schema::InputObject)
|
8
|
+
mutation_base_class = Class.new(GraphQL::Schema::RelayClassicMutation) do
|
9
|
+
input_object_class(custom_input)
|
10
|
+
end
|
11
|
+
mutation_subclass = Class.new(mutation_base_class)
|
12
|
+
|
13
|
+
assert_equal GraphQL::Schema::InputObject, GraphQL::Schema::RelayClassicMutation.input_object_class
|
14
|
+
assert_equal custom_input, mutation_base_class.input_object_class
|
15
|
+
assert_equal custom_input, mutation_subclass.input_object_class
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe ".input_type" do
|
20
|
+
it "has a reference to the mutation" do
|
21
|
+
mutation = Class.new(GraphQL::Schema::RelayClassicMutation) do
|
22
|
+
graphql_name "Test"
|
23
|
+
end
|
24
|
+
assert_equal mutation, mutation.input_type.mutation
|
25
|
+
assert_equal mutation, mutation.input_type.graphql_definition.mutation
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".null" do
|
30
|
+
it "is inherited as true" do
|
31
|
+
mutation = Class.new(GraphQL::Schema::RelayClassicMutation) do
|
32
|
+
graphql_name "Test"
|
33
|
+
end
|
34
|
+
|
35
|
+
assert mutation.null
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -25,6 +25,17 @@ describe GraphQL::Schema::RescueMiddleware do
|
|
25
25
|
assert_equal(GraphQL::ExecutionError, result.class)
|
26
26
|
end
|
27
27
|
|
28
|
+
describe "rescue_from superclass" do
|
29
|
+
class ChildSpecExampleError < SpecExampleError; end
|
30
|
+
|
31
|
+
let(:error_class) { ChildSpecExampleError }
|
32
|
+
it "handles them as execution errors" do
|
33
|
+
result = middleware_chain.invoke([])
|
34
|
+
assert_equal("there was an example error: ChildSpecExampleError", result.message)
|
35
|
+
assert_equal(GraphQL::ExecutionError, result.class)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
28
39
|
describe "with multiple error classes" do
|
29
40
|
let(:error_class) { SecondSpecExampleError }
|
30
41
|
let(:rescue_middleware) do
|
@@ -0,0 +1,131 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe GraphQL::Schema::Resolver do
|
5
|
+
module ResolverTest
|
6
|
+
class BaseResolver < GraphQL::Schema::Resolver
|
7
|
+
end
|
8
|
+
|
9
|
+
class Resolver1 < BaseResolver
|
10
|
+
argument :value, Integer, required: false
|
11
|
+
type [Integer, null: true], null: false
|
12
|
+
|
13
|
+
def initialize(object:, context:)
|
14
|
+
super
|
15
|
+
if defined?(@value)
|
16
|
+
raise "The instance should start fresh"
|
17
|
+
end
|
18
|
+
@value = [100]
|
19
|
+
end
|
20
|
+
|
21
|
+
def resolve(value: nil)
|
22
|
+
@value << value
|
23
|
+
@value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Resolver2 < Resolver1
|
28
|
+
argument :extra_value, Integer, required: true
|
29
|
+
|
30
|
+
def resolve(extra_value:, **_rest)
|
31
|
+
value = super(_rest)
|
32
|
+
value << extra_value
|
33
|
+
value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Resolver3 < Resolver1
|
38
|
+
end
|
39
|
+
|
40
|
+
class Resolver4 < BaseResolver
|
41
|
+
type Integer, null: false
|
42
|
+
|
43
|
+
extras [:ast_node]
|
44
|
+
def resolve(ast_node:)
|
45
|
+
object.value + ast_node.name.size
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
class Resolver5 < Resolver4
|
50
|
+
end
|
51
|
+
|
52
|
+
class Query < GraphQL::Schema::Object
|
53
|
+
class CustomField < GraphQL::Schema::Field
|
54
|
+
def resolve_field(*args)
|
55
|
+
value = super
|
56
|
+
if @name == "resolver3"
|
57
|
+
value << -1
|
58
|
+
end
|
59
|
+
value
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
field_class(CustomField)
|
64
|
+
|
65
|
+
field :resolver_1, resolver: Resolver1
|
66
|
+
field :resolver_2, resolver: Resolver2
|
67
|
+
field :resolver_3, resolver: Resolver3
|
68
|
+
field :resolver_3_again, resolver: Resolver3, description: "field desc"
|
69
|
+
field :resolver_4, "Positional description", resolver: Resolver4
|
70
|
+
field :resolver_5, resolver: Resolver5
|
71
|
+
end
|
72
|
+
|
73
|
+
class Schema < GraphQL::Schema
|
74
|
+
query(Query)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it "gets initialized for each resolution" do
|
79
|
+
# State isn't shared between calls:
|
80
|
+
res = ResolverTest::Schema.execute " { r1: resolver1(value: 1) r2: resolver1 }"
|
81
|
+
assert_equal [100, 1], res["data"]["r1"]
|
82
|
+
assert_equal [100, nil], res["data"]["r2"]
|
83
|
+
end
|
84
|
+
|
85
|
+
it "inherits type and arguments" do
|
86
|
+
res = ResolverTest::Schema.execute " { r1: resolver2(value: 1, extraValue: 2) r2: resolver2(extraValue: 3) }"
|
87
|
+
assert_equal [100, 1, 2], res["data"]["r1"]
|
88
|
+
assert_equal [100, nil, 3], res["data"]["r2"]
|
89
|
+
end
|
90
|
+
|
91
|
+
it "uses the object's field_class" do
|
92
|
+
res = ResolverTest::Schema.execute " { r1: resolver3(value: 1) r2: resolver3 }"
|
93
|
+
assert_equal [100, 1, -1], res["data"]["r1"]
|
94
|
+
assert_equal [100, nil, -1], res["data"]["r2"]
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "resolve method" do
|
98
|
+
it "has access to the application object" do
|
99
|
+
res = ResolverTest::Schema.execute " { resolver4 } ", root_value: OpenStruct.new(value: 4)
|
100
|
+
assert_equal 13, res["data"]["resolver4"]
|
101
|
+
end
|
102
|
+
|
103
|
+
it "gets extras" do
|
104
|
+
res = ResolverTest::Schema.execute " { resolver4 } ", root_value: OpenStruct.new(value: 0)
|
105
|
+
assert_equal 9, res["data"]["resolver4"]
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "extras" do
|
110
|
+
it "is inherited" do
|
111
|
+
res = ResolverTest::Schema.execute " { resolver4 resolver5 } ", root_value: OpenStruct.new(value: 0)
|
112
|
+
assert_equal 9, res["data"]["resolver4"]
|
113
|
+
assert_equal 9, res["data"]["resolver5"]
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "when applied to a field" do
|
118
|
+
it "gets the field's description" do
|
119
|
+
assert_nil ResolverTest::Schema.find("Query.resolver3").description
|
120
|
+
assert_equal "field desc", ResolverTest::Schema.find("Query.resolver3Again").description
|
121
|
+
assert_equal "Positional description", ResolverTest::Schema.find("Query.resolver4").description
|
122
|
+
end
|
123
|
+
|
124
|
+
it "gets the field's name" do
|
125
|
+
# Matching name:
|
126
|
+
assert ResolverTest::Schema.find("Query.resolver3")
|
127
|
+
# Mismatched name:
|
128
|
+
assert ResolverTest::Schema.find("Query.resolver3Again")
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe GraphQL::Schema::Scalar do
|
5
|
+
describe "in queries" do
|
6
|
+
it "becomes output" do
|
7
|
+
query_str = <<-GRAPHQL
|
8
|
+
{
|
9
|
+
find(id: "Musician/Herbie Hancock") {
|
10
|
+
... on Musician {
|
11
|
+
name
|
12
|
+
favoriteKey
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
GRAPHQL
|
17
|
+
|
18
|
+
res = Jazz::Schema.execute(query_str)
|
19
|
+
assert_equal "B♭", res["data"]["find"]["favoriteKey"]
|
20
|
+
end
|
21
|
+
|
22
|
+
it "can be input" do
|
23
|
+
query_str = <<-GRAPHQL
|
24
|
+
{
|
25
|
+
inspectKey(key: "F♯") {
|
26
|
+
root
|
27
|
+
isSharp
|
28
|
+
isFlat
|
29
|
+
}
|
30
|
+
}
|
31
|
+
GRAPHQL
|
32
|
+
|
33
|
+
res = Jazz::Schema.execute(query_str)
|
34
|
+
key_info = res["data"]["inspectKey"]
|
35
|
+
assert_equal "F", key_info["root"]
|
36
|
+
assert_equal true, key_info["isSharp"]
|
37
|
+
assert_equal false, key_info["isFlat"]
|
38
|
+
end
|
39
|
+
|
40
|
+
it "can be nested JSON" do
|
41
|
+
query_str = <<-GRAPHQL
|
42
|
+
{
|
43
|
+
echoJson(input: {foo: [{bar: "baz"}]})
|
44
|
+
}
|
45
|
+
GRAPHQL
|
46
|
+
|
47
|
+
res = Jazz::Schema.execute(query_str)
|
48
|
+
assert_equal({"foo" => [{"bar" => "baz"}]}, res["data"]["echoJson"])
|
49
|
+
end
|
50
|
+
|
51
|
+
it "can be a JSON array" do
|
52
|
+
query_str = <<-GRAPHQL
|
53
|
+
{
|
54
|
+
echoFirstJson(input: [{foo: "bar"}, {baz: "boo"}])
|
55
|
+
}
|
56
|
+
GRAPHQL
|
57
|
+
|
58
|
+
res = Jazz::Schema.execute(query_str)
|
59
|
+
assert_equal({"foo" => "bar"}, res["data"]["echoFirstJson"])
|
60
|
+
end
|
61
|
+
|
62
|
+
it "can be a JSON array even if the GraphQL type is not an array" do
|
63
|
+
query_str = <<-GRAPHQL
|
64
|
+
{
|
65
|
+
echoJson(input: [{foo: "bar"}])
|
66
|
+
}
|
67
|
+
GRAPHQL
|
68
|
+
|
69
|
+
res = Jazz::Schema.execute(query_str)
|
70
|
+
assert_equal([{"foo" => "bar"}], res["data"]["echoJson"])
|
71
|
+
end
|
72
|
+
|
73
|
+
it "can be JSON with a nested enum" do
|
74
|
+
query_str = <<-GRAPHQL
|
75
|
+
{
|
76
|
+
echoJson(input: [{foo: WOODWIND}])
|
77
|
+
}
|
78
|
+
GRAPHQL
|
79
|
+
|
80
|
+
res = Jazz::Schema.execute(query_str)
|
81
|
+
assert_equal([{"foo" => "WOODWIND"}], res["data"]["echoJson"])
|
82
|
+
end
|
83
|
+
|
84
|
+
it "cannot be JSON with a nested variable" do
|
85
|
+
query_str = <<-GRAPHQL
|
86
|
+
{
|
87
|
+
echoJson(input: [{foo: $var}])
|
88
|
+
}
|
89
|
+
GRAPHQL
|
90
|
+
|
91
|
+
res = Jazz::Schema.execute(query_str)
|
92
|
+
assert_includes(res["errors"][0]["message"], "Argument 'input' on Field 'echoJson' has an invalid value")
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -188,4 +188,35 @@ describe GraphQL::Schema::Traversal do
|
|
188
188
|
}
|
189
189
|
assert_equal expected, result
|
190
190
|
end
|
191
|
+
|
192
|
+
it "finds orphan types from interfaces" do
|
193
|
+
b_type = GraphQL::ObjectType.define do
|
194
|
+
name "B"
|
195
|
+
end
|
196
|
+
|
197
|
+
c_type = GraphQL::ObjectType.define do
|
198
|
+
name "C"
|
199
|
+
end
|
200
|
+
|
201
|
+
interface = GraphQL::InterfaceType.define do
|
202
|
+
name "AInterface"
|
203
|
+
orphan_types [b_type]
|
204
|
+
end
|
205
|
+
|
206
|
+
another_interface = GraphQL::InterfaceType.define do
|
207
|
+
name "AnotherIterface"
|
208
|
+
orphan_types [b_type, c_type]
|
209
|
+
end
|
210
|
+
|
211
|
+
result = traversal([interface, another_interface]).type_map
|
212
|
+
expected = {
|
213
|
+
"Boolean" => GraphQL::BOOLEAN_TYPE,
|
214
|
+
"String" => GraphQL::STRING_TYPE,
|
215
|
+
"AInterface" => interface,
|
216
|
+
"AnotherIterface" => another_interface,
|
217
|
+
"B" => b_type,
|
218
|
+
"C" => c_type
|
219
|
+
}
|
220
|
+
assert_equal expected, result
|
221
|
+
end
|
191
222
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe GraphQL::Schema::Union do
|
5
|
+
let(:union) { Jazz::PerformingAct }
|
6
|
+
describe "type info" do
|
7
|
+
it "has some" do
|
8
|
+
assert_equal 2, union.possible_types.size
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe ".to_graphql" do
|
13
|
+
it "creates a UnionType" do
|
14
|
+
union = Class.new(GraphQL::Schema::Union) do
|
15
|
+
possible_types Jazz::Musician, Jazz::Ensemble
|
16
|
+
|
17
|
+
def self.name
|
18
|
+
"MyUnion"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
union_type = union.to_graphql
|
22
|
+
assert_equal "MyUnion", union_type.name
|
23
|
+
assert_equal [Jazz::Musician.to_graphql, Jazz::Ensemble.to_graphql], union_type.possible_types
|
24
|
+
assert_nil union_type.resolve_type_proc
|
25
|
+
end
|
26
|
+
|
27
|
+
it "can specify a resolve_type method" do
|
28
|
+
union = Class.new(GraphQL::Schema::Union) do
|
29
|
+
def self.resolve_type(_object, _context)
|
30
|
+
"MyType"
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.name
|
34
|
+
"MyUnion"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
union_type = union.to_graphql
|
38
|
+
assert_equal "MyType", union_type.resolve_type_proc.call(nil, nil)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "in queries" do
|
43
|
+
it "works" do
|
44
|
+
query_str = <<-GRAPHQL
|
45
|
+
{
|
46
|
+
nowPlaying {
|
47
|
+
... on Musician {
|
48
|
+
name
|
49
|
+
instrument {
|
50
|
+
family
|
51
|
+
}
|
52
|
+
}
|
53
|
+
... on Ensemble {
|
54
|
+
name
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
GRAPHQL
|
59
|
+
|
60
|
+
res = Jazz::Schema.execute(query_str)
|
61
|
+
expected_data = { "name" => "Bela Fleck and the Flecktones" }
|
62
|
+
assert_equal expected_data, res["data"]["nowPlaying"]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -333,7 +333,7 @@ describe GraphQL::Schema::Validation do
|
|
333
333
|
end
|
334
334
|
|
335
335
|
it "allows null default value for nullable argument" do
|
336
|
-
|
336
|
+
assert_nil GraphQL::Schema::Validation.validate(null_default_value)
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
@@ -242,8 +242,8 @@ describe GraphQL::Schema::Warden do
|
|
242
242
|
GRAPHQL
|
243
243
|
res = MaskHelpers.query_with_mask(query_string, mask)
|
244
244
|
assert_equal "Query", res["data"]["__schema"]["queryType"]["name"]
|
245
|
-
|
246
|
-
|
245
|
+
assert_nil res["data"]["__schema"]["mutationType"]
|
246
|
+
assert_nil res["data"]["__schema"]["subscriptionType"]
|
247
247
|
type_names = res["data"]["__schema"]["types"].map { |t| t["name"] }
|
248
248
|
refute type_names.include?("Mutation")
|
249
249
|
refute type_names.include?("Subscription")
|
@@ -344,7 +344,7 @@ describe GraphQL::Schema::Warden do
|
|
344
344
|
res = MaskHelpers.run_query(query_string, only: whitelist)
|
345
345
|
|
346
346
|
# It's not visible by name
|
347
|
-
|
347
|
+
assert_nil res["data"]["Phoneme"]
|
348
348
|
|
349
349
|
# It's not visible in `__schema`
|
350
350
|
all_type_names = type_names(res)
|
@@ -423,7 +423,7 @@ describe GraphQL::Schema::Warden do
|
|
423
423
|
|
424
424
|
res = MaskHelpers.query_with_mask(query_string, mask)
|
425
425
|
type = res["data"]["__type"]
|
426
|
-
|
426
|
+
assert_nil type
|
427
427
|
end
|
428
428
|
end
|
429
429
|
end
|
@@ -543,7 +543,7 @@ describe GraphQL::Schema::Warden do
|
|
543
543
|
|
544
544
|
res = MaskHelpers.query_with_mask(query_string, mask)
|
545
545
|
|
546
|
-
|
546
|
+
assert_nil res["data"]["WithinInput"], "The type isn't accessible by name"
|
547
547
|
|
548
548
|
languages_arg_names = res["data"]["Query"]["fields"].find { |f| f["name"] == "languages" }["args"].map { |a| a["name"] }
|
549
549
|
refute_includes languages_arg_names, "within", "Arguments that point to it are gone"
|
@@ -666,7 +666,7 @@ describe GraphQL::Schema::Warden do
|
|
666
666
|
it "is additive with query filters" do
|
667
667
|
query_except = ->(member, ctx) { member.metadata[:hidden_input_object_type] }
|
668
668
|
res = schema.execute(query_str, except: query_except)
|
669
|
-
|
669
|
+
assert_nil res["data"]["input"]
|
670
670
|
enum_values = res["data"]["enum"]["enumValues"].map { |v| v["name"] }
|
671
671
|
refute_includes enum_values, "TRILL"
|
672
672
|
end
|
@@ -695,13 +695,13 @@ describe GraphQL::Schema::Warden do
|
|
695
695
|
only: [visible_enum_value, visible_abstract_type],
|
696
696
|
except: [hidden_input_object, hidden_type],
|
697
697
|
)
|
698
|
-
|
698
|
+
assert_nil res["data"]["input"]
|
699
699
|
enum_values = res["data"]["enum"]["enumValues"].map { |v| v["name"] }
|
700
700
|
assert_equal 5, enum_values.length
|
701
701
|
refute_includes enum_values, "TRILL"
|
702
702
|
# These are also filtered out:
|
703
703
|
assert_equal 0, res["data"]["abstractType"]["interfaces"].length
|
704
|
-
|
704
|
+
assert_nil res["data"]["type"]
|
705
705
|
end
|
706
706
|
end
|
707
707
|
|
@@ -712,7 +712,7 @@ describe GraphQL::Schema::Warden do
|
|
712
712
|
except: hidden_input_object,
|
713
713
|
}
|
714
714
|
res = MaskHelpers.run_query(query_str, context: { filters: filters })
|
715
|
-
|
715
|
+
assert_nil res["data"]["input"]
|
716
716
|
enum_values = res["data"]["enum"]["enumValues"].map { |v| v["name"] }
|
717
717
|
assert_equal 5, enum_values.length
|
718
718
|
refute_includes enum_values, "TRILL"
|
@@ -727,13 +727,13 @@ describe GraphQL::Schema::Warden do
|
|
727
727
|
except: [hidden_input_object, hidden_type],
|
728
728
|
}
|
729
729
|
res = MaskHelpers.run_query(query_str, context: { filters: filters })
|
730
|
-
|
730
|
+
assert_nil res["data"]["input"]
|
731
731
|
enum_values = res["data"]["enum"]["enumValues"].map { |v| v["name"] }
|
732
732
|
assert_equal 5, enum_values.length
|
733
733
|
refute_includes enum_values, "TRILL"
|
734
734
|
# These are also filtered out:
|
735
735
|
assert_equal 0, res["data"]["abstractType"]["interfaces"].length
|
736
|
-
|
736
|
+
assert_nil res["data"]["type"]
|
737
737
|
end
|
738
738
|
end
|
739
739
|
end
|