graphql 1.9.11 → 1.9.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/graphql/analysis/ast/query_complexity.rb +0 -8
- data/lib/graphql/analysis/ast/query_depth.rb +0 -8
- data/lib/graphql/analysis/ast/visitor.rb +26 -24
- data/lib/graphql/execution.rb +1 -0
- data/lib/graphql/execution/errors.rb +60 -0
- data/lib/graphql/execution/interpreter/runtime.rb +21 -17
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +15 -8
- data/lib/graphql/version.rb +1 -1
- metadata +5 -556
- data/spec/dummy/Gemfile +0 -12
- data/spec/dummy/README.md +0 -24
- data/spec/dummy/Rakefile +0 -7
- data/spec/dummy/app/assets/config/manifest.js +0 -1
- data/spec/dummy/app/assets/javascripts/application.js +0 -66
- data/spec/dummy/app/channels/application_cable/channel.rb +0 -5
- data/spec/dummy/app/channels/application_cable/connection.rb +0 -5
- data/spec/dummy/app/channels/graphql_channel.rb +0 -116
- data/spec/dummy/app/controllers/application_controller.rb +0 -4
- data/spec/dummy/app/controllers/pages_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -3
- data/spec/dummy/app/jobs/application_job.rb +0 -3
- data/spec/dummy/app/views/layouts/application.html.erb +0 -12
- data/spec/dummy/app/views/pages/show.html +0 -16
- data/spec/dummy/bin/bundle +0 -4
- data/spec/dummy/bin/rails +0 -5
- data/spec/dummy/bin/rake +0 -5
- data/spec/dummy/bin/setup +0 -31
- data/spec/dummy/bin/update +0 -27
- data/spec/dummy/bin/yarn +0 -12
- data/spec/dummy/config.ru +0 -6
- data/spec/dummy/config/application.rb +0 -30
- data/spec/dummy/config/boot.rb +0 -4
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/environment.rb +0 -6
- data/spec/dummy/config/environments/development.rb +0 -40
- data/spec/dummy/config/environments/production.rb +0 -76
- data/spec/dummy/config/environments/test.rb +0 -37
- data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -9
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -8
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -6
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -5
- data/spec/dummy/config/initializers/inflections.rb +0 -17
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -10
- data/spec/dummy/config/locales/en.yml +0 -33
- data/spec/dummy/config/puma.rb +0 -57
- data/spec/dummy/config/routes.rb +0 -4
- data/spec/dummy/config/secrets.yml +0 -32
- data/spec/dummy/package.json +0 -5
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/robots.txt +0 -1
- data/spec/dummy/test/application_system_test_case.rb +0 -6
- data/spec/dummy/test/system/action_cable_subscription_test.rb +0 -45
- data/spec/dummy/test/test_helper.rb +0 -4
- data/spec/fixtures/upgrader/account.original.rb +0 -19
- data/spec/fixtures/upgrader/account.transformed.rb +0 -20
- data/spec/fixtures/upgrader/blame_range.original.rb +0 -43
- data/spec/fixtures/upgrader/blame_range.transformed.rb +0 -30
- data/spec/fixtures/upgrader/date_time.original.rb +0 -24
- data/spec/fixtures/upgrader/date_time.transformed.rb +0 -23
- data/spec/fixtures/upgrader/delete_project.original.rb +0 -28
- data/spec/fixtures/upgrader/delete_project.transformed.rb +0 -27
- data/spec/fixtures/upgrader/gist_order_field.original.rb +0 -14
- data/spec/fixtures/upgrader/gist_order_field.transformed.rb +0 -13
- data/spec/fixtures/upgrader/increment_count.original.rb +0 -59
- data/spec/fixtures/upgrader/increment_count.transformed.rb +0 -50
- data/spec/fixtures/upgrader/mutation.original.rb +0 -28
- data/spec/fixtures/upgrader/mutation.transformed.rb +0 -28
- data/spec/fixtures/upgrader/photo.original.rb +0 -10
- data/spec/fixtures/upgrader/photo.transformed.rb +0 -12
- data/spec/fixtures/upgrader/release_order.original.rb +0 -15
- data/spec/fixtures/upgrader/release_order.transformed.rb +0 -14
- data/spec/fixtures/upgrader/starrable.original.rb +0 -49
- data/spec/fixtures/upgrader/starrable.transformed.rb +0 -46
- data/spec/fixtures/upgrader/subscribable.original.rb +0 -55
- data/spec/fixtures/upgrader/subscribable.transformed.rb +0 -51
- data/spec/fixtures/upgrader/type_x.original.rb +0 -65
- data/spec/fixtures/upgrader/type_x.transformed.rb +0 -56
- data/spec/graphql/analysis/analyze_query_spec.rb +0 -261
- data/spec/graphql/analysis/ast/field_usage_spec.rb +0 -51
- data/spec/graphql/analysis/ast/max_query_complexity_spec.rb +0 -120
- data/spec/graphql/analysis/ast/max_query_depth_spec.rb +0 -134
- data/spec/graphql/analysis/ast/query_complexity_spec.rb +0 -299
- data/spec/graphql/analysis/ast/query_depth_spec.rb +0 -108
- data/spec/graphql/analysis/ast_spec.rb +0 -296
- data/spec/graphql/analysis/field_usage_spec.rb +0 -62
- data/spec/graphql/analysis/max_query_complexity_spec.rb +0 -102
- data/spec/graphql/analysis/max_query_depth_spec.rb +0 -103
- data/spec/graphql/analysis/query_complexity_spec.rb +0 -301
- data/spec/graphql/analysis/query_depth_spec.rb +0 -81
- data/spec/graphql/argument_spec.rb +0 -159
- data/spec/graphql/authorization_spec.rb +0 -974
- data/spec/graphql/backtrace_spec.rb +0 -206
- data/spec/graphql/base_type_spec.rb +0 -171
- data/spec/graphql/boolean_type_spec.rb +0 -21
- data/spec/graphql/compatibility/execution_specification_spec.rb +0 -4
- data/spec/graphql/compatibility/lazy_execution_specification_spec.rb +0 -4
- data/spec/graphql/compatibility/query_parser_specification_spec.rb +0 -6
- data/spec/graphql/compatibility/schema_parser_specification_spec.rb +0 -6
- data/spec/graphql/define/assign_argument_spec.rb +0 -61
- data/spec/graphql/define/instance_definable_spec.rb +0 -203
- data/spec/graphql/directive/skip_directive_spec.rb +0 -9
- data/spec/graphql/directive_spec.rb +0 -295
- data/spec/graphql/enum_type_spec.rb +0 -158
- data/spec/graphql/execution/execute_spec.rb +0 -303
- data/spec/graphql/execution/instrumentation_spec.rb +0 -212
- data/spec/graphql/execution/interpreter_spec.rb +0 -485
- data/spec/graphql/execution/lazy/lazy_method_map_spec.rb +0 -57
- data/spec/graphql/execution/lazy_spec.rb +0 -247
- data/spec/graphql/execution/lookahead_spec.rb +0 -390
- data/spec/graphql/execution/multiplex_spec.rb +0 -222
- data/spec/graphql/execution/typecast_spec.rb +0 -47
- data/spec/graphql/execution_error_spec.rb +0 -329
- data/spec/graphql/field_spec.rb +0 -246
- data/spec/graphql/float_type_spec.rb +0 -16
- data/spec/graphql/function_spec.rb +0 -152
- data/spec/graphql/id_type_spec.rb +0 -33
- data/spec/graphql/input_object_type_spec.rb +0 -25
- data/spec/graphql/int_type_spec.rb +0 -35
- data/spec/graphql/interface_type_spec.rb +0 -196
- data/spec/graphql/internal_representation/print_spec.rb +0 -41
- data/spec/graphql/internal_representation/rewrite_spec.rb +0 -381
- data/spec/graphql/introspection/directive_type_spec.rb +0 -66
- data/spec/graphql/introspection/input_value_type_spec.rb +0 -144
- data/spec/graphql/introspection/introspection_query_spec.rb +0 -64
- data/spec/graphql/introspection/schema_type_spec.rb +0 -57
- data/spec/graphql/introspection/type_type_spec.rb +0 -155
- data/spec/graphql/language/block_string_spec.rb +0 -70
- data/spec/graphql/language/definition_slice_spec.rb +0 -226
- data/spec/graphql/language/document_from_schema_definition_spec.rb +0 -770
- data/spec/graphql/language/equality_spec.rb +0 -84
- data/spec/graphql/language/generation_spec.rb +0 -38
- data/spec/graphql/language/lexer_spec.rb +0 -153
- data/spec/graphql/language/nodes_spec.rb +0 -67
- data/spec/graphql/language/parser_spec.rb +0 -183
- data/spec/graphql/language/printer_spec.rb +0 -215
- data/spec/graphql/language/visitor_spec.rb +0 -419
- data/spec/graphql/list_type_spec.rb +0 -57
- data/spec/graphql/non_null_type_spec.rb +0 -48
- data/spec/graphql/object_type_spec.rb +0 -197
- data/spec/graphql/query/arguments_spec.rb +0 -346
- data/spec/graphql/query/context_spec.rb +0 -292
- data/spec/graphql/query/executor_spec.rb +0 -341
- data/spec/graphql/query/literal_input_spec.rb +0 -91
- data/spec/graphql/query/result_spec.rb +0 -29
- data/spec/graphql/query/serial_execution/value_resolution_spec.rb +0 -109
- data/spec/graphql/query_spec.rb +0 -803
- data/spec/graphql/rake_task_spec.rb +0 -59
- data/spec/graphql/scalar_type_spec.rb +0 -66
- data/spec/graphql/schema/argument_spec.rb +0 -186
- data/spec/graphql/schema/build_from_definition_spec.rb +0 -1197
- data/spec/graphql/schema/catchall_middleware_spec.rb +0 -32
- data/spec/graphql/schema/directive/feature_spec.rb +0 -81
- data/spec/graphql/schema/directive/transform_spec.rb +0 -39
- data/spec/graphql/schema/enum_spec.rb +0 -83
- data/spec/graphql/schema/enum_value_spec.rb +0 -24
- data/spec/graphql/schema/field_extension_spec.rb +0 -159
- data/spec/graphql/schema/field_spec.rb +0 -319
- data/spec/graphql/schema/finder_spec.rb +0 -135
- data/spec/graphql/schema/input_object_spec.rb +0 -421
- data/spec/graphql/schema/instrumentation_spec.rb +0 -43
- data/spec/graphql/schema/interface_spec.rb +0 -215
- data/spec/graphql/schema/introspection_system_spec.rb +0 -80
- data/spec/graphql/schema/list_spec.rb +0 -73
- data/spec/graphql/schema/loader_spec.rb +0 -350
- data/spec/graphql/schema/member/accepts_definition_spec.rb +0 -115
- data/spec/graphql/schema/member/build_type_spec.rb +0 -63
- data/spec/graphql/schema/member/scoped_spec.rb +0 -217
- data/spec/graphql/schema/member/type_system_helpers_spec.rb +0 -63
- data/spec/graphql/schema/middleware_chain_spec.rb +0 -57
- data/spec/graphql/schema/mutation_spec.rb +0 -150
- data/spec/graphql/schema/non_null_spec.rb +0 -46
- data/spec/graphql/schema/object_spec.rb +0 -355
- data/spec/graphql/schema/printer_spec.rb +0 -883
- data/spec/graphql/schema/relay_classic_mutation_spec.rb +0 -252
- data/spec/graphql/schema/rescue_middleware_spec.rb +0 -88
- data/spec/graphql/schema/resolver_spec.rb +0 -743
- data/spec/graphql/schema/scalar_spec.rb +0 -101
- data/spec/graphql/schema/subscription_spec.rb +0 -505
- data/spec/graphql/schema/timeout_middleware_spec.rb +0 -188
- data/spec/graphql/schema/timeout_spec.rb +0 -206
- data/spec/graphql/schema/traversal_spec.rb +0 -222
- data/spec/graphql/schema/type_expression_spec.rb +0 -39
- data/spec/graphql/schema/union_spec.rb +0 -72
- data/spec/graphql/schema/unique_within_type_spec.rb +0 -44
- data/spec/graphql/schema/validation_spec.rb +0 -355
- data/spec/graphql/schema/warden_spec.rb +0 -926
- data/spec/graphql/schema_spec.rb +0 -169
- data/spec/graphql/static_validation/rules/argument_literals_are_compatible_spec.rb +0 -466
- data/spec/graphql/static_validation/rules/argument_names_are_unique_spec.rb +0 -44
- data/spec/graphql/static_validation/rules/arguments_are_defined_spec.rb +0 -112
- data/spec/graphql/static_validation/rules/directives_are_defined_spec.rb +0 -35
- data/spec/graphql/static_validation/rules/directives_are_in_valid_locations_spec.rb +0 -42
- data/spec/graphql/static_validation/rules/fields_are_defined_on_type_spec.rb +0 -167
- data/spec/graphql/static_validation/rules/fields_have_appropriate_selections_spec.rb +0 -66
- data/spec/graphql/static_validation/rules/fields_will_merge_spec.rb +0 -740
- data/spec/graphql/static_validation/rules/fragment_names_are_unique_spec.rb +0 -28
- data/spec/graphql/static_validation/rules/fragment_spreads_are_possible_spec.rb +0 -52
- data/spec/graphql/static_validation/rules/fragment_types_exist_spec.rb +0 -42
- data/spec/graphql/static_validation/rules/fragments_are_finite_spec.rb +0 -123
- data/spec/graphql/static_validation/rules/fragments_are_named_spec.rb +0 -24
- data/spec/graphql/static_validation/rules/fragments_are_on_composite_types_spec.rb +0 -56
- data/spec/graphql/static_validation/rules/fragments_are_used_spec.rb +0 -61
- data/spec/graphql/static_validation/rules/mutation_root_exists_spec.rb +0 -39
- data/spec/graphql/static_validation/rules/no_definitions_are_present_spec.rb +0 -62
- data/spec/graphql/static_validation/rules/operation_names_are_valid_spec.rb +0 -82
- data/spec/graphql/static_validation/rules/required_arguments_are_present_spec.rb +0 -98
- data/spec/graphql/static_validation/rules/required_input_object_attributes_are_present_spec.rb +0 -86
- data/spec/graphql/static_validation/rules/subscription_root_exists_spec.rb +0 -34
- data/spec/graphql/static_validation/rules/unique_directives_per_location_spec.rb +0 -188
- data/spec/graphql/static_validation/rules/variable_default_values_are_correctly_typed_spec.rb +0 -196
- data/spec/graphql/static_validation/rules/variable_names_are_unique_spec.rb +0 -23
- data/spec/graphql/static_validation/rules/variable_usages_are_allowed_spec.rb +0 -236
- data/spec/graphql/static_validation/rules/variables_are_input_types_spec.rb +0 -78
- data/spec/graphql/static_validation/rules/variables_are_used_and_defined_spec.rb +0 -81
- data/spec/graphql/static_validation/type_stack_spec.rb +0 -29
- data/spec/graphql/static_validation/validator_spec.rb +0 -204
- data/spec/graphql/string_type_spec.rb +0 -80
- data/spec/graphql/subscriptions/serialize_spec.rb +0 -49
- data/spec/graphql/subscriptions_spec.rb +0 -540
- data/spec/graphql/tracing/new_relic_tracing_spec.rb +0 -84
- data/spec/graphql/tracing/platform_tracing_spec.rb +0 -141
- data/spec/graphql/tracing/prometheus_tracing_spec.rb +0 -42
- data/spec/graphql/tracing/scout_tracing_spec.rb +0 -17
- data/spec/graphql/tracing/skylight_tracing_spec.rb +0 -63
- data/spec/graphql/tracing_spec.rb +0 -52
- data/spec/graphql/types/big_int_spec.rb +0 -24
- data/spec/graphql/types/iso_8601_date_time_spec.rb +0 -137
- data/spec/graphql/types/relay/base_edge_spec.rb +0 -33
- data/spec/graphql/union_type_spec.rb +0 -211
- data/spec/graphql/upgrader/member_spec.rb +0 -583
- data/spec/graphql/upgrader/schema_spec.rb +0 -82
- data/spec/integration/mongoid/graphql/relay/mongo_relation_connection_spec.rb +0 -528
- data/spec/integration/mongoid/spec_helper.rb +0 -2
- data/spec/integration/mongoid/star_trek/data.rb +0 -126
- data/spec/integration/mongoid/star_trek/schema.rb +0 -424
- data/spec/integration/rails/data.rb +0 -110
- data/spec/integration/rails/generators/base_generator_test.rb +0 -7
- data/spec/integration/rails/generators/graphql/enum_generator_spec.rb +0 -30
- data/spec/integration/rails/generators/graphql/install_generator_spec.rb +0 -238
- data/spec/integration/rails/generators/graphql/interface_generator_spec.rb +0 -34
- data/spec/integration/rails/generators/graphql/loader_generator_spec.rb +0 -59
- data/spec/integration/rails/generators/graphql/mutation_generator_spec.rb +0 -71
- data/spec/integration/rails/generators/graphql/object_generator_spec.rb +0 -54
- data/spec/integration/rails/generators/graphql/scalar_generator_spec.rb +0 -28
- data/spec/integration/rails/generators/graphql/union_generator_spec.rb +0 -67
- data/spec/integration/rails/graphql/input_object_spec.rb +0 -19
- data/spec/integration/rails/graphql/input_object_type_spec.rb +0 -364
- data/spec/integration/rails/graphql/query/variables_spec.rb +0 -375
- data/spec/integration/rails/graphql/relay/array_connection_spec.rb +0 -309
- data/spec/integration/rails/graphql/relay/base_connection_spec.rb +0 -101
- data/spec/integration/rails/graphql/relay/connection_instrumentation_spec.rb +0 -80
- data/spec/integration/rails/graphql/relay/connection_resolve_spec.rb +0 -79
- data/spec/integration/rails/graphql/relay/connection_type_spec.rb +0 -106
- data/spec/integration/rails/graphql/relay/edge_spec.rb +0 -10
- data/spec/integration/rails/graphql/relay/mutation_spec.rb +0 -387
- data/spec/integration/rails/graphql/relay/node_spec.rb +0 -263
- data/spec/integration/rails/graphql/relay/page_info_spec.rb +0 -111
- data/spec/integration/rails/graphql/relay/range_add_spec.rb +0 -117
- data/spec/integration/rails/graphql/relay/relation_connection_spec.rb +0 -837
- data/spec/integration/rails/graphql/schema_spec.rb +0 -507
- data/spec/integration/rails/graphql/tracing/active_support_notifications_tracing_spec.rb +0 -62
- data/spec/integration/rails/spec_helper.rb +0 -25
- data/spec/spec_helper.rb +0 -116
- data/spec/support/dummy/data.rb +0 -45
- data/spec/support/dummy/schema.rb +0 -519
- data/spec/support/error_bubbling_helpers.rb +0 -23
- data/spec/support/global_id.rb +0 -23
- data/spec/support/jazz.rb +0 -778
- data/spec/support/lazy_helpers.rb +0 -192
- data/spec/support/magic_cards/schema.graphql +0 -33
- data/spec/support/minimum_input_object.rb +0 -21
- data/spec/support/new_relic.rb +0 -27
- data/spec/support/parser/filename_example.graphql +0 -5
- data/spec/support/parser/filename_example_error_1.graphql +0 -4
- data/spec/support/parser/filename_example_error_2.graphql +0 -5
- data/spec/support/parser/filename_example_invalid_utf8.graphql +0 -1
- data/spec/support/skylight.rb +0 -39
- data/spec/support/star_wars/schema.rb +0 -464
- data/spec/support/static_validation_helpers.rb +0 -32
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe GraphQL::Schema::TypeExpression do
|
5
|
-
let(:types) { Dummy::Schema.types }
|
6
|
-
let(:ast_node) {
|
7
|
-
document = GraphQL.parse("query dostuff($var: #{type_name}) { id } ")
|
8
|
-
document.definitions.first.variables.first.type
|
9
|
-
}
|
10
|
-
let(:type_expression_result) { GraphQL::Schema::TypeExpression.build_type(types, ast_node) }
|
11
|
-
|
12
|
-
describe "#type" do
|
13
|
-
describe "simple types" do
|
14
|
-
let(:type_name) { "DairyProductInput" }
|
15
|
-
it "it gets types from the provided types" do
|
16
|
-
assert_equal(Dummy::DairyProductInput.graphql_definition, type_expression_result)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "non-null types" do
|
21
|
-
let(:type_name) { "String!"}
|
22
|
-
it "makes non-null types" do
|
23
|
-
assert_equal(GraphQL::STRING_TYPE.to_non_null_type,type_expression_result)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "list types" do
|
28
|
-
let(:type_name) { "[DairyAnimal!]!" }
|
29
|
-
|
30
|
-
it "makes list types" do
|
31
|
-
expected = Dummy::DairyAnimal.graphql_definition
|
32
|
-
.to_non_null_type
|
33
|
-
.to_list_type
|
34
|
-
.to_non_null_type
|
35
|
-
assert_equal(expected, type_expression_result)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe GraphQL::Schema::Union do
|
5
|
-
let(:union) { Jazz::PerformingAct }
|
6
|
-
|
7
|
-
describe ".path" do
|
8
|
-
it "is the name" do
|
9
|
-
assert_equal "PerformingAct", union.path
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "type info" do
|
14
|
-
it "has some" do
|
15
|
-
assert_equal 2, union.possible_types.size
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe ".to_graphql" do
|
20
|
-
it "creates a UnionType" do
|
21
|
-
union = Class.new(GraphQL::Schema::Union) do
|
22
|
-
possible_types Jazz::Musician, Jazz::Ensemble
|
23
|
-
|
24
|
-
def self.name
|
25
|
-
"MyUnion"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
union_type = union.to_graphql
|
29
|
-
assert_equal "MyUnion", union_type.name
|
30
|
-
assert_equal [Jazz::Musician.to_graphql, Jazz::Ensemble.to_graphql], union_type.possible_types
|
31
|
-
assert_nil union_type.resolve_type_proc
|
32
|
-
end
|
33
|
-
|
34
|
-
it "can specify a resolve_type method" do
|
35
|
-
union = Class.new(GraphQL::Schema::Union) do
|
36
|
-
def self.resolve_type(_object, _context)
|
37
|
-
"MyType"
|
38
|
-
end
|
39
|
-
|
40
|
-
def self.name
|
41
|
-
"MyUnion"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
union_type = union.to_graphql
|
45
|
-
assert_equal "MyType", union_type.resolve_type_proc.call(nil, nil)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe "in queries" do
|
50
|
-
it "works" do
|
51
|
-
query_str = <<-GRAPHQL
|
52
|
-
{
|
53
|
-
nowPlaying {
|
54
|
-
... on Musician {
|
55
|
-
name
|
56
|
-
instrument {
|
57
|
-
family
|
58
|
-
}
|
59
|
-
}
|
60
|
-
... on Ensemble {
|
61
|
-
name
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
65
|
-
GRAPHQL
|
66
|
-
|
67
|
-
res = Jazz::Schema.execute(query_str)
|
68
|
-
expected_data = { "name" => "Bela Fleck and the Flecktones" }
|
69
|
-
assert_equal expected_data, res["data"]["nowPlaying"]
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe GraphQL::Schema::UniqueWithinType do
|
5
|
-
describe 'encode / decode' do
|
6
|
-
it 'Converts typename and ID to and from ID' do
|
7
|
-
global_id = GraphQL::Schema::UniqueWithinType.encode("SomeType", 123)
|
8
|
-
type_name, id = GraphQL::Schema::UniqueWithinType.decode(global_id)
|
9
|
-
assert_equal("SomeType", type_name)
|
10
|
-
assert_equal("123", id)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "allows you specify default separator" do
|
14
|
-
GraphQL::Schema::UniqueWithinType.default_id_separator = '|'
|
15
|
-
global_id = GraphQL::Schema::UniqueWithinType.encode("Type-With-UUID", "250cda0e-a89d-41cf-99e1-2872d89f1100")
|
16
|
-
type_name, id = GraphQL::Schema::UniqueWithinType.decode(global_id)
|
17
|
-
assert_equal("Type-With-UUID", type_name)
|
18
|
-
assert_equal("250cda0e-a89d-41cf-99e1-2872d89f1100", id)
|
19
|
-
GraphQL::Schema::UniqueWithinType.default_id_separator = '-'
|
20
|
-
end
|
21
|
-
|
22
|
-
it "allows you to specify the separator" do
|
23
|
-
custom_separator = "---"
|
24
|
-
global_id = GraphQL::Schema::UniqueWithinType.encode("Type-With-UUID", "250cda0e-a89d-41cf-99e1-2872d89f1100", separator: custom_separator)
|
25
|
-
type_name, id = GraphQL::Schema::UniqueWithinType.decode(global_id, separator: custom_separator)
|
26
|
-
assert_equal("Type-With-UUID", type_name)
|
27
|
-
assert_equal("250cda0e-a89d-41cf-99e1-2872d89f1100", id)
|
28
|
-
end
|
29
|
-
|
30
|
-
it "allows using the separator in the ID" do
|
31
|
-
global_id = GraphQL::Schema::UniqueWithinType.encode("SomeUUIDType", "250cda0e-a89d-41cf-99e1-2872d89f1100")
|
32
|
-
type_name, id = GraphQL::Schema::UniqueWithinType.decode(global_id)
|
33
|
-
assert_equal("SomeUUIDType", type_name)
|
34
|
-
assert_equal("250cda0e-a89d-41cf-99e1-2872d89f1100", id)
|
35
|
-
end
|
36
|
-
|
37
|
-
it "raises an error if you try and use a reserved character in the typename" do
|
38
|
-
err = assert_raises(RuntimeError) {
|
39
|
-
GraphQL::Schema::UniqueWithinType.encode("Best-Thing", "234-567")
|
40
|
-
}
|
41
|
-
assert_includes err.message, "encode(Best-Thing, 234-567) contains reserved characters `-` in the type name"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
@@ -1,355 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe GraphQL::Schema::Validation do
|
5
|
-
def integer_class_name
|
6
|
-
RUBY_VERSION >= "2.4.0" ? "Integer" : "Fixnum"
|
7
|
-
end
|
8
|
-
|
9
|
-
def assert_error_includes(object, error_substring)
|
10
|
-
validation_error = GraphQL::Schema::Validation.validate(object)
|
11
|
-
assert_includes validation_error, error_substring
|
12
|
-
end
|
13
|
-
|
14
|
-
def refute_error_includes(object, *error_substrings)
|
15
|
-
validation_error = GraphQL::Schema::Validation.validate(object)
|
16
|
-
error_substrings.each do |substr|
|
17
|
-
refute_includes(validation_error, substr)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def assert_validation_warns(object, warning)
|
22
|
-
assert_output("", warning + "\n") { GraphQL::Schema::Validation.validate(object) }
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "validating Fields" do
|
26
|
-
let(:unnamed_field) {
|
27
|
-
GraphQL::Field.define do
|
28
|
-
type GraphQL::STRING_TYPE
|
29
|
-
end
|
30
|
-
}
|
31
|
-
|
32
|
-
let(:invalid_name_field) {
|
33
|
-
GraphQL::Field.define do
|
34
|
-
name "__Something"
|
35
|
-
type GraphQL::STRING_TYPE
|
36
|
-
end
|
37
|
-
}
|
38
|
-
|
39
|
-
let(:untyped_field) {
|
40
|
-
GraphQL::Field.define do
|
41
|
-
name "Untyped"
|
42
|
-
type :something_invalid
|
43
|
-
end
|
44
|
-
}
|
45
|
-
|
46
|
-
let(:bad_arguments_field) {
|
47
|
-
field = GraphQL::Field.define do
|
48
|
-
name "BadArgs"
|
49
|
-
type !GraphQL::BOOLEAN_TYPE
|
50
|
-
end
|
51
|
-
field.arguments[:bad_key] = :bad_value
|
52
|
-
field
|
53
|
-
}
|
54
|
-
|
55
|
-
let(:invalid_argument_member_field) {
|
56
|
-
GraphQL::Field.define do
|
57
|
-
name "InvalidArgument"
|
58
|
-
type !types[!GraphQL::INT_TYPE]
|
59
|
-
argument :invalid do
|
60
|
-
type GraphQL::FLOAT_TYPE
|
61
|
-
default_value [1,2,3]
|
62
|
-
end
|
63
|
-
end
|
64
|
-
}
|
65
|
-
|
66
|
-
it "requires a String for name" do
|
67
|
-
assert_error_includes unnamed_field, "must return String, not NilClass"
|
68
|
-
end
|
69
|
-
|
70
|
-
it "cannot use reserved name" do
|
71
|
-
assert_validation_warns invalid_name_field, 'Name "__Something" must not begin with "__", which is reserved by GraphQL introspection.'
|
72
|
-
end
|
73
|
-
|
74
|
-
it "requires a BaseType for type" do
|
75
|
-
assert_error_includes untyped_field, "must return GraphQL::BaseType, not Symbol"
|
76
|
-
end
|
77
|
-
|
78
|
-
it "requires String => Argument arguments" do
|
79
|
-
assert_error_includes bad_arguments_field, "must map String => GraphQL::Argument, not Symbol => Symbol"
|
80
|
-
end
|
81
|
-
|
82
|
-
it "applies validation to its member Arguments" do
|
83
|
-
assert_error_includes invalid_argument_member_field, "default value [1, 2, 3] is not valid for type Float"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe "validating BaseType" do
|
88
|
-
let(:unnamed_type) {
|
89
|
-
GraphQL::BaseType.define do
|
90
|
-
name :invalid_name
|
91
|
-
end
|
92
|
-
}
|
93
|
-
|
94
|
-
let(:invalid_name_type) {
|
95
|
-
GraphQL::BaseType.define do
|
96
|
-
name '__Something'
|
97
|
-
end
|
98
|
-
}
|
99
|
-
|
100
|
-
let(:wrongly_described_type) {
|
101
|
-
GraphQL::BaseType.define do
|
102
|
-
name "WronglyDescribed"
|
103
|
-
description 12345
|
104
|
-
end
|
105
|
-
}
|
106
|
-
|
107
|
-
it "requires a String name" do
|
108
|
-
assert_error_includes unnamed_type, "must return String, not Symbol"
|
109
|
-
end
|
110
|
-
|
111
|
-
it "cannot use reserved name" do
|
112
|
-
assert_validation_warns invalid_name_type, 'Name "__Something" must not begin with "__", which is reserved by GraphQL introspection.'
|
113
|
-
end
|
114
|
-
|
115
|
-
it "requires String-or-nil description" do
|
116
|
-
assert_error_includes wrongly_described_type, "must return String or NilClass, not #{integer_class_name}"
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
describe "validating ObjectTypes" do
|
121
|
-
let(:invalid_interface_member_object) {
|
122
|
-
GraphQL::ObjectType.define do
|
123
|
-
name "InvalidInterfaceMember"
|
124
|
-
interfaces [:not_an_interface]
|
125
|
-
end
|
126
|
-
}
|
127
|
-
|
128
|
-
let(:invalid_field_object) {
|
129
|
-
GraphQL::ObjectType.define do
|
130
|
-
name "InvalidField"
|
131
|
-
field :invalid, :nonsense
|
132
|
-
end
|
133
|
-
}
|
134
|
-
|
135
|
-
it "requires an Array for interfaces" do
|
136
|
-
assert_error_includes invalid_interface_member_object, "must contain GraphQL::InterfaceType, not Symbol"
|
137
|
-
end
|
138
|
-
|
139
|
-
it "validates the fields" do
|
140
|
-
assert_error_includes invalid_field_object, "must return GraphQL::BaseType, not Symbol"
|
141
|
-
end
|
142
|
-
|
143
|
-
it "requires interfaces to be implemented" do
|
144
|
-
iface_1 = GraphQL::InterfaceType.define do
|
145
|
-
name "Interface1"
|
146
|
-
field :field_1, types.String
|
147
|
-
field :field_2, types.Int
|
148
|
-
end
|
149
|
-
|
150
|
-
iface_2 = GraphQL::InterfaceType.define do
|
151
|
-
name "Interface2"
|
152
|
-
field :field_3, types.String do
|
153
|
-
argument :arg_1, types.Boolean
|
154
|
-
end
|
155
|
-
field :field_4, types.Int
|
156
|
-
end
|
157
|
-
|
158
|
-
iface_3 = GraphQL::InterfaceType.define do
|
159
|
-
name "Interface3"
|
160
|
-
field :field_5, types.String do
|
161
|
-
argument :arg_2, types.Float
|
162
|
-
end
|
163
|
-
field :field_6, types.Int do
|
164
|
-
argument :arg_3, types.Float
|
165
|
-
end
|
166
|
-
field :field_7, types.ID
|
167
|
-
field :field_8, !types[iface_2]
|
168
|
-
field :field_9, !types[iface_2]
|
169
|
-
end
|
170
|
-
|
171
|
-
obj_type = GraphQL::ObjectType.define do
|
172
|
-
name "Object1"
|
173
|
-
implements iface_1, inherit: true
|
174
|
-
implements iface_2, iface_3
|
175
|
-
field :field_2, types.Int do
|
176
|
-
# Acceptable extra optional argument:
|
177
|
-
argument :arg_0_extra, types.String
|
178
|
-
# Unacceptable extra required argument:
|
179
|
-
argument :arg_0_extra_2, !types.String
|
180
|
-
end
|
181
|
-
# Correct:
|
182
|
-
field :field_3, types.String do
|
183
|
-
argument :arg_1, types.Boolean
|
184
|
-
end
|
185
|
-
# Wrong return type:
|
186
|
-
field :field_4, types.Float
|
187
|
-
# Wrong argument type:
|
188
|
-
field :field_5, types.String do
|
189
|
-
argument :arg_2, types.Int
|
190
|
-
end
|
191
|
-
# Missing argument
|
192
|
-
field :field_6, types.Int
|
193
|
-
# Missing altogether:
|
194
|
-
# field :field_7
|
195
|
-
# Valid subtype:
|
196
|
-
field :field_8, !types[!iface_2]
|
197
|
-
# Invalid subtype:
|
198
|
-
field :field_9, types[iface_2]
|
199
|
-
end
|
200
|
-
|
201
|
-
assert_error_includes(obj_type, '"arg_0_extra_2" is not accepted by Interface1.field_2 but required by Object1.field_2')
|
202
|
-
assert_error_includes(obj_type, '"field_4" is required by Interface2 to return Int but Object1.field_4 returns Float')
|
203
|
-
assert_error_includes(obj_type, '"arg_2" is required by Interface3.field_5 to accept Float but Object1.field_5 accepts Int for "arg_2"')
|
204
|
-
assert_error_includes(obj_type, '"field_7" is required by Interface3 but not implemented by Object1')
|
205
|
-
assert_error_includes(obj_type, '"field_9" is required by Interface3 to return [Interface2]! but Object1.field_9 returns [Interface2]')
|
206
|
-
refute_error_includes(obj_type, "field_1", "field_3", "field_8")
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
describe "validating UnionTypes" do
|
211
|
-
let(:non_array_union) {
|
212
|
-
GraphQL::UnionType.define do
|
213
|
-
name "NonArray"
|
214
|
-
possible_types 55
|
215
|
-
end
|
216
|
-
}
|
217
|
-
|
218
|
-
let(:non_object_type_union) {
|
219
|
-
GraphQL::UnionType.define do
|
220
|
-
name "NonObjectTypes"
|
221
|
-
possible_types [
|
222
|
-
GraphQL::InterfaceType.new
|
223
|
-
]
|
224
|
-
end
|
225
|
-
}
|
226
|
-
|
227
|
-
let(:no_possible_types_union) {
|
228
|
-
GraphQL::UnionType.define do
|
229
|
-
name "NoPossibleTypes"
|
230
|
-
possible_types []
|
231
|
-
end
|
232
|
-
}
|
233
|
-
|
234
|
-
it "requires an array of ObjectTypes for possible_types" do
|
235
|
-
assert_error_includes non_array_union, "must be an Array of GraphQL::ObjectType, not a #{integer_class_name}"
|
236
|
-
|
237
|
-
assert_error_includes non_object_type_union, "must contain GraphQL::ObjectType, not GraphQL::InterfaceType"
|
238
|
-
end
|
239
|
-
|
240
|
-
it "requires at least one possible_types" do
|
241
|
-
assert_error_includes no_possible_types_union, "must have at least one possible type"
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
describe "validating InputObjectTypes" do
|
246
|
-
let(:invalid_arguments_input) {
|
247
|
-
input = GraphQL::InputObjectType.define do
|
248
|
-
name "InvalidArgumentsHash"
|
249
|
-
end
|
250
|
-
input.arguments[123] = :nonsense
|
251
|
-
input
|
252
|
-
}
|
253
|
-
|
254
|
-
let(:invalid_argument_member_input) {
|
255
|
-
GraphQL::InputObjectType.define do
|
256
|
-
name "InvalidArgumentMember"
|
257
|
-
argument :nonsense do
|
258
|
-
type GraphQL::FLOAT_TYPE
|
259
|
-
default_value ["xyz"]
|
260
|
-
end
|
261
|
-
end
|
262
|
-
}
|
263
|
-
|
264
|
-
it "requires {String => Argument} arguments" do
|
265
|
-
assert_error_includes invalid_arguments_input, "map String => GraphQL::Argument, not #{integer_class_name} => Symbol"
|
266
|
-
end
|
267
|
-
|
268
|
-
it "applies validation to its member Arguments" do
|
269
|
-
assert_error_includes invalid_argument_member_input, "default value [\"xyz\"] is not valid for type Float"
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
describe "validating InterfaceTypes" do
|
274
|
-
let(:invalid_field_interface) {
|
275
|
-
GraphQL::InterfaceType.define do
|
276
|
-
name "InvalidField"
|
277
|
-
field :invalid do
|
278
|
-
type GraphQL::BOOLEAN_TYPE
|
279
|
-
argument :invalid do
|
280
|
-
type GraphQL::FLOAT_TYPE
|
281
|
-
default_value ["123"]
|
282
|
-
end
|
283
|
-
end
|
284
|
-
end
|
285
|
-
}
|
286
|
-
|
287
|
-
it "validates fields" do
|
288
|
-
assert_error_includes invalid_field_interface, "default value [\"123\"] is not valid for type Float"
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
describe "validating Arguments" do
|
293
|
-
let(:untyped_argument) {
|
294
|
-
GraphQL::Argument.define do
|
295
|
-
name "Untyped"
|
296
|
-
type :Bogus
|
297
|
-
end
|
298
|
-
}
|
299
|
-
|
300
|
-
let(:default_argument_for_non_null_argument) {
|
301
|
-
GraphQL::Argument.define do
|
302
|
-
name "ValidDefault"
|
303
|
-
type !GraphQL::INT_TYPE
|
304
|
-
default_value 1
|
305
|
-
end
|
306
|
-
}
|
307
|
-
|
308
|
-
let(:invalid_name_argument) {
|
309
|
-
GraphQL::Argument.define do
|
310
|
-
name "__Something"
|
311
|
-
type GraphQL::INT_TYPE
|
312
|
-
end
|
313
|
-
}
|
314
|
-
|
315
|
-
let(:null_default_value) {
|
316
|
-
GraphQL::Argument.define do
|
317
|
-
name "NullDefault"
|
318
|
-
type Dummy::DairyAnimal
|
319
|
-
default_value nil
|
320
|
-
end
|
321
|
-
}
|
322
|
-
|
323
|
-
it "requires the type is a Base type" do
|
324
|
-
assert_error_includes untyped_argument, "must be a valid input type (Scalar or InputObject), not Symbol"
|
325
|
-
end
|
326
|
-
|
327
|
-
it "allows default values for non-null argument" do
|
328
|
-
assert_nil GraphQL::Schema::Validation.validate(default_argument_for_non_null_argument)
|
329
|
-
end
|
330
|
-
|
331
|
-
it "cannot use reserved name" do
|
332
|
-
assert_validation_warns invalid_name_argument, 'Name "__Something" must not begin with "__", which is reserved by GraphQL introspection.'
|
333
|
-
end
|
334
|
-
|
335
|
-
it "allows null default value for nullable argument" do
|
336
|
-
assert_nil GraphQL::Schema::Validation.validate(null_default_value)
|
337
|
-
end
|
338
|
-
end
|
339
|
-
|
340
|
-
describe "validating instrumentation" do
|
341
|
-
let(:schema) {
|
342
|
-
query_type = GraphQL::ObjectType.define(name: "Query")
|
343
|
-
GraphQL::Schema.define do
|
344
|
-
query(query_type)
|
345
|
-
instrument(:field, 1)
|
346
|
-
instrument(:query, :oops)
|
347
|
-
end
|
348
|
-
}
|
349
|
-
it "finds instrumenters missing methods" do
|
350
|
-
err = assert_raises(NotImplementedError) { schema }
|
351
|
-
assert_includes err.message, "before_query(query)"
|
352
|
-
assert_includes err.message, "instrument(type, field)"
|
353
|
-
end
|
354
|
-
end
|
355
|
-
end
|