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,70 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe GraphQL::Language::BlockString do
|
5
|
-
describe "trimming whitespace" do
|
6
|
-
def trim_whitespace(str)
|
7
|
-
GraphQL::Language::BlockString.trim_whitespace(str)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "matches the examples in graphql-js" do
|
11
|
-
# these are taken from:
|
12
|
-
# https://github.com/graphql/graphql-js/blob/36ec0e9d34666362ff0e2b2b18edeb98e3c9abee/src/language/__tests__/blockStringValue-test.js#L12
|
13
|
-
# A set of [before, after] pairs:
|
14
|
-
examples = [
|
15
|
-
[
|
16
|
-
# Removes common whitespace:
|
17
|
-
"
|
18
|
-
Hello,
|
19
|
-
World!
|
20
|
-
|
21
|
-
Yours,
|
22
|
-
GraphQL.
|
23
|
-
",
|
24
|
-
"Hello,\n World!\n\nYours,\n GraphQL."
|
25
|
-
],
|
26
|
-
[
|
27
|
-
# Removes leading and trailing newlines:
|
28
|
-
"
|
29
|
-
|
30
|
-
Hello,
|
31
|
-
World!
|
32
|
-
|
33
|
-
Yours,
|
34
|
-
GraphQL.
|
35
|
-
|
36
|
-
",
|
37
|
-
"Hello,\n World!\n\nYours,\n GraphQL."
|
38
|
-
],
|
39
|
-
[
|
40
|
-
# Removes blank lines (with whitespace _and_ newlines:)
|
41
|
-
"\n \n
|
42
|
-
Hello,
|
43
|
-
World!
|
44
|
-
|
45
|
-
Yours,
|
46
|
-
GraphQL.
|
47
|
-
|
48
|
-
\n \n",
|
49
|
-
"Hello,\n World!\n\nYours,\n GraphQL."
|
50
|
-
],
|
51
|
-
[
|
52
|
-
# Retains indentation from the first line
|
53
|
-
" Hello,\n World!\n\n Yours,\n GraphQL.",
|
54
|
-
" Hello,\n World!\n\nYours,\n GraphQL.",
|
55
|
-
],
|
56
|
-
[
|
57
|
-
# Doesn't alter trailing spaces
|
58
|
-
"\n \n Hello, \n World! \n\n Yours, \n GraphQL. ",
|
59
|
-
"Hello, \n World! \n\nYours, \n GraphQL. ",
|
60
|
-
|
61
|
-
],
|
62
|
-
]
|
63
|
-
|
64
|
-
examples.each_with_index do |(before, after), idx|
|
65
|
-
transformed_str = trim_whitespace(before)
|
66
|
-
assert_equal(after, transformed_str, "Example ##{idx + 1}")
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,226 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe GraphQL::Language::DefinitionSlice do
|
5
|
-
let(:document) { GraphQL::Language::Parser.parse(query_string) }
|
6
|
-
|
7
|
-
describe "anonymous query with no dependencies" do
|
8
|
-
let(:query_string) {%|
|
9
|
-
{
|
10
|
-
version
|
11
|
-
}
|
12
|
-
|}
|
13
|
-
|
14
|
-
it "is already the smallest slice" do
|
15
|
-
assert_equal document.to_query_string,
|
16
|
-
document.slice_definition(nil).to_query_string
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "anonymous mutation with no dependencies" do
|
21
|
-
let(:query_string) {%|
|
22
|
-
mutation {
|
23
|
-
ping {
|
24
|
-
message
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|}
|
28
|
-
|
29
|
-
it "is already the smallest slice" do
|
30
|
-
assert_equal document.to_query_string,
|
31
|
-
document.slice_definition(nil).to_query_string
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "anonymous fragment with no dependencies" do
|
36
|
-
let(:query_string) {%|
|
37
|
-
fragment on User {
|
38
|
-
name
|
39
|
-
}
|
40
|
-
|}
|
41
|
-
|
42
|
-
it "is already the smallest slice" do
|
43
|
-
assert_equal document.to_query_string,
|
44
|
-
document.slice_definition(nil).to_query_string
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe "named query with no dependencies" do
|
49
|
-
let(:query_string) {%|
|
50
|
-
query getVersion {
|
51
|
-
version
|
52
|
-
}
|
53
|
-
|}
|
54
|
-
|
55
|
-
it "is already the smallest slice" do
|
56
|
-
assert_equal document.to_query_string,
|
57
|
-
document.slice_definition("getVersion").to_query_string
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "named fragment with no dependencies" do
|
62
|
-
let(:query_string) {%|
|
63
|
-
fragment profileFields on User {
|
64
|
-
firstName
|
65
|
-
lastName
|
66
|
-
}
|
67
|
-
|}
|
68
|
-
|
69
|
-
it "is already the smallest slice" do
|
70
|
-
assert_equal document.to_query_string,
|
71
|
-
document.slice_definition("profileFields").to_query_string
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
describe "document with multiple queries but no subdependencies" do
|
76
|
-
let(:query_string) {%|
|
77
|
-
query getVersion {
|
78
|
-
version
|
79
|
-
}
|
80
|
-
|
81
|
-
query getTime {
|
82
|
-
time
|
83
|
-
}
|
84
|
-
|}
|
85
|
-
|
86
|
-
it "returns just the query definition" do
|
87
|
-
assert_equal GraphQL::Language::Nodes::Document.new(definitions: [document.definitions[0]]).to_query_string,
|
88
|
-
document.slice_definition("getVersion").to_query_string
|
89
|
-
assert_equal GraphQL::Language::Nodes::Document.new(definitions: [document.definitions[1]]).to_query_string,
|
90
|
-
document.slice_definition("getTime").to_query_string
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "document with multiple fragments but no subdependencies" do
|
95
|
-
let(:query_string) {%|
|
96
|
-
fragment profileFields on User {
|
97
|
-
firstName
|
98
|
-
lastName
|
99
|
-
}
|
100
|
-
|
101
|
-
fragment avatarFields on User {
|
102
|
-
avatarURL(size: 80)
|
103
|
-
}
|
104
|
-
|}
|
105
|
-
|
106
|
-
it "returns just the fragment definition" do
|
107
|
-
assert_equal GraphQL::Language::Nodes::Document.new(definitions: [document.definitions[0]]).to_query_string,
|
108
|
-
document.slice_definition("profileFields").to_query_string
|
109
|
-
assert_equal GraphQL::Language::Nodes::Document.new(definitions: [document.definitions[1]]).to_query_string,
|
110
|
-
document.slice_definition("avatarFields").to_query_string
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "query with missing spread" do
|
115
|
-
let(:query_string) {%|
|
116
|
-
query getUser {
|
117
|
-
viewer {
|
118
|
-
...profileFields
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|}
|
122
|
-
|
123
|
-
it "is ignored" do
|
124
|
-
assert_equal document.to_query_string,
|
125
|
-
document.slice_definition("getUser").to_query_string
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
describe "query and fragment subdependency" do
|
130
|
-
let(:query_string) {%|
|
131
|
-
query getUser {
|
132
|
-
viewer {
|
133
|
-
...profileFields
|
134
|
-
}
|
135
|
-
}
|
136
|
-
|
137
|
-
fragment profileFields on User {
|
138
|
-
firstName
|
139
|
-
lastName
|
140
|
-
}
|
141
|
-
|}
|
142
|
-
|
143
|
-
it "returns query and fragment dependency" do
|
144
|
-
assert_equal document.to_query_string,
|
145
|
-
document.slice_definition("getUser").to_query_string
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe "query and fragment nested subdependencies" do
|
150
|
-
let(:query_string) {%|
|
151
|
-
query getUser {
|
152
|
-
viewer {
|
153
|
-
...viewerInfo
|
154
|
-
}
|
155
|
-
}
|
156
|
-
|
157
|
-
fragment viewerInfo on User {
|
158
|
-
...profileFields
|
159
|
-
}
|
160
|
-
|
161
|
-
fragment profileFields on User {
|
162
|
-
firstName
|
163
|
-
lastName
|
164
|
-
...avatarFields
|
165
|
-
}
|
166
|
-
|
167
|
-
fragment avatarFields on User {
|
168
|
-
avatarURL(size: 80)
|
169
|
-
}
|
170
|
-
|}
|
171
|
-
|
172
|
-
it "returns query and all fragment dependencies" do
|
173
|
-
assert_equal document.to_query_string,
|
174
|
-
document.slice_definition("getUser").to_query_string
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
describe "fragment subdependency referenced multiple times" do
|
179
|
-
let(:query_string) {%|
|
180
|
-
query getUser {
|
181
|
-
viewer {
|
182
|
-
...viewerInfo
|
183
|
-
...moreViewerInfo
|
184
|
-
}
|
185
|
-
}
|
186
|
-
|
187
|
-
fragment viewerInfo on User {
|
188
|
-
...profileFields
|
189
|
-
}
|
190
|
-
|
191
|
-
fragment moreViewerInfo on User {
|
192
|
-
...profileFields
|
193
|
-
}
|
194
|
-
|
195
|
-
fragment profileFields on User {
|
196
|
-
firstName
|
197
|
-
lastName
|
198
|
-
}
|
199
|
-
|}
|
200
|
-
|
201
|
-
it "is only returned once" do
|
202
|
-
assert_equal document.to_query_string,
|
203
|
-
document.slice_definition("getUser").to_query_string
|
204
|
-
end
|
205
|
-
end
|
206
|
-
|
207
|
-
describe "query and unused fragment" do
|
208
|
-
let(:query_string) {%|
|
209
|
-
query getUser {
|
210
|
-
viewer {
|
211
|
-
id
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
fragment profileFields on User {
|
216
|
-
firstName
|
217
|
-
lastName
|
218
|
-
}
|
219
|
-
|}
|
220
|
-
|
221
|
-
it "returns just the query definition" do
|
222
|
-
assert_equal GraphQL::Language::Nodes::Document.new(definitions: [document.definitions[0]]).to_query_string,
|
223
|
-
document.slice_definition("getUser").to_query_string
|
224
|
-
end
|
225
|
-
end
|
226
|
-
end
|
@@ -1,770 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe GraphQL::Language::DocumentFromSchemaDefinition do
|
5
|
-
let(:subject) { GraphQL::Language::DocumentFromSchemaDefinition }
|
6
|
-
|
7
|
-
describe "#document" do
|
8
|
-
let(:schema_idl) { <<-GRAPHQL
|
9
|
-
type QueryType {
|
10
|
-
foo: Foo
|
11
|
-
}
|
12
|
-
|
13
|
-
type Foo implements Bar {
|
14
|
-
one: Type
|
15
|
-
two(argument: InputType!): Site
|
16
|
-
three(argument: InputType, other: String): CustomScalar
|
17
|
-
four(argument: String = "string"): String
|
18
|
-
five(argument: [String] = ["string", "string"]): String
|
19
|
-
six(argument: String): Type
|
20
|
-
}
|
21
|
-
|
22
|
-
interface Bar {
|
23
|
-
one: Type
|
24
|
-
four(argument: String = "string"): String
|
25
|
-
}
|
26
|
-
|
27
|
-
type Type {
|
28
|
-
a: String
|
29
|
-
}
|
30
|
-
|
31
|
-
input InputType {
|
32
|
-
key: String!
|
33
|
-
answer: Int = 42
|
34
|
-
}
|
35
|
-
|
36
|
-
type MutationType {
|
37
|
-
a(input: InputType): String
|
38
|
-
}
|
39
|
-
|
40
|
-
# Scalar description
|
41
|
-
scalar CustomScalar
|
42
|
-
|
43
|
-
enum Site {
|
44
|
-
DESKTOP
|
45
|
-
MOBILE
|
46
|
-
}
|
47
|
-
|
48
|
-
union Union = Type | QueryType
|
49
|
-
|
50
|
-
schema {
|
51
|
-
query: QueryType
|
52
|
-
mutation: MutationType
|
53
|
-
}
|
54
|
-
GRAPHQL
|
55
|
-
}
|
56
|
-
|
57
|
-
let(:schema) { GraphQL::Schema.from_definition(schema_idl) }
|
58
|
-
|
59
|
-
let(:expected_document) { GraphQL.parse(expected_idl) }
|
60
|
-
|
61
|
-
describe "when printing and schema respects root name conventions" do
|
62
|
-
let(:schema_idl) { <<-GRAPHQL
|
63
|
-
type Query {
|
64
|
-
foo: Foo
|
65
|
-
}
|
66
|
-
|
67
|
-
type Foo implements Bar {
|
68
|
-
one: Type
|
69
|
-
two(argument: InputType!): Site
|
70
|
-
three(argument: InputType, other: String): CustomScalar
|
71
|
-
four(argument: String = "string"): String
|
72
|
-
five(argument: [String] = ["string", "string"]): String
|
73
|
-
six(argument: String): Type
|
74
|
-
}
|
75
|
-
|
76
|
-
interface Bar {
|
77
|
-
one: Type
|
78
|
-
four(argument: String = "string"): String
|
79
|
-
}
|
80
|
-
|
81
|
-
type Type {
|
82
|
-
a: String
|
83
|
-
}
|
84
|
-
|
85
|
-
input InputType {
|
86
|
-
key: String!
|
87
|
-
answer: Int = 42
|
88
|
-
}
|
89
|
-
|
90
|
-
type Mutation {
|
91
|
-
a(input: InputType): String
|
92
|
-
}
|
93
|
-
|
94
|
-
# Scalar description
|
95
|
-
scalar CustomScalar
|
96
|
-
|
97
|
-
enum Site {
|
98
|
-
DESKTOP
|
99
|
-
MOBILE
|
100
|
-
}
|
101
|
-
|
102
|
-
union Union = Type | Query
|
103
|
-
|
104
|
-
schema {
|
105
|
-
query: Query
|
106
|
-
mutation: Mutation
|
107
|
-
}
|
108
|
-
GRAPHQL
|
109
|
-
}
|
110
|
-
|
111
|
-
let(:expected_idl) { <<-GRAPHQL
|
112
|
-
type QueryType {
|
113
|
-
foo: Foo
|
114
|
-
}
|
115
|
-
|
116
|
-
type Foo implements Bar {
|
117
|
-
one: Type
|
118
|
-
two(argument: InputType!): Site
|
119
|
-
three(argument: InputType, other: String): CustomScalar
|
120
|
-
four(argument: String = "string"): String
|
121
|
-
five(argument: [String] = ["string", "string"]): String
|
122
|
-
six(argument: String): Type
|
123
|
-
}
|
124
|
-
|
125
|
-
interface Bar {
|
126
|
-
one: Type
|
127
|
-
four(argument: String = "string"): String
|
128
|
-
}
|
129
|
-
|
130
|
-
type Type {
|
131
|
-
a: String
|
132
|
-
}
|
133
|
-
|
134
|
-
input InputType {
|
135
|
-
key: String!
|
136
|
-
answer: Int = 42
|
137
|
-
}
|
138
|
-
|
139
|
-
type MutationType {
|
140
|
-
a(input: InputType): String
|
141
|
-
}
|
142
|
-
|
143
|
-
# Scalar description
|
144
|
-
scalar CustomScalar
|
145
|
-
|
146
|
-
enum Site {
|
147
|
-
DESKTOP
|
148
|
-
MOBILE
|
149
|
-
}
|
150
|
-
|
151
|
-
union Union = Type | QueryType
|
152
|
-
GRAPHQL
|
153
|
-
}
|
154
|
-
|
155
|
-
let(:document) {
|
156
|
-
subject.new(
|
157
|
-
schema
|
158
|
-
).document
|
159
|
-
}
|
160
|
-
|
161
|
-
it "returns the IDL without introspection, built ins and schema root" do
|
162
|
-
assert equivalent_node?(expected_document, document)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
describe "with defaults" do
|
167
|
-
let(:expected_idl) { <<-GRAPHQL
|
168
|
-
type QueryType {
|
169
|
-
foo: Foo
|
170
|
-
}
|
171
|
-
|
172
|
-
type Foo implements Bar {
|
173
|
-
one: Type
|
174
|
-
two(argument: InputType!): Site
|
175
|
-
three(argument: InputType, other: String): CustomScalar
|
176
|
-
four(argument: String = "string"): String
|
177
|
-
five(argument: [String] = ["string", "string"]): String
|
178
|
-
six(argument: String): Type
|
179
|
-
}
|
180
|
-
|
181
|
-
interface Bar {
|
182
|
-
one: Type
|
183
|
-
four(argument: String = "string"): String
|
184
|
-
}
|
185
|
-
|
186
|
-
type Type {
|
187
|
-
a: String
|
188
|
-
}
|
189
|
-
|
190
|
-
input InputType {
|
191
|
-
key: String!
|
192
|
-
answer: Int = 42
|
193
|
-
}
|
194
|
-
|
195
|
-
type MutationType {
|
196
|
-
a(input: InputType): String
|
197
|
-
}
|
198
|
-
|
199
|
-
# Scalar description
|
200
|
-
scalar CustomScalar
|
201
|
-
|
202
|
-
enum Site {
|
203
|
-
DESKTOP
|
204
|
-
MOBILE
|
205
|
-
}
|
206
|
-
|
207
|
-
union Union = Type | QueryType
|
208
|
-
|
209
|
-
schema {
|
210
|
-
query: QueryType
|
211
|
-
mutation: MutationType
|
212
|
-
}
|
213
|
-
GRAPHQL
|
214
|
-
}
|
215
|
-
|
216
|
-
let(:document) {
|
217
|
-
subject.new(
|
218
|
-
schema
|
219
|
-
).document
|
220
|
-
}
|
221
|
-
|
222
|
-
it "returns the IDL without introspection, built ins and schema if it doesnt respect name conventions" do
|
223
|
-
assert equivalent_node?(expected_document, document)
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
describe "with an except filter" do
|
228
|
-
let(:expected_idl) { <<-GRAPHQL
|
229
|
-
type QueryType {
|
230
|
-
foo: Foo
|
231
|
-
}
|
232
|
-
|
233
|
-
type Foo implements Bar {
|
234
|
-
three(argument: InputType, other: String): CustomScalar
|
235
|
-
four(argument: String = "string"): String
|
236
|
-
five(argument: [String] = ["string", "string"]): Site
|
237
|
-
}
|
238
|
-
|
239
|
-
interface Bar {
|
240
|
-
one: Type
|
241
|
-
four(argument: String = "string"): String
|
242
|
-
}
|
243
|
-
|
244
|
-
input InputType {
|
245
|
-
key: String!
|
246
|
-
answer: Int = 42
|
247
|
-
}
|
248
|
-
|
249
|
-
type MutationType {
|
250
|
-
a(input: InputType): String
|
251
|
-
}
|
252
|
-
|
253
|
-
# Scalar description
|
254
|
-
scalar CustomScalar
|
255
|
-
|
256
|
-
enum Site {
|
257
|
-
DESKTOP
|
258
|
-
MOBILE
|
259
|
-
}
|
260
|
-
|
261
|
-
schema {
|
262
|
-
query: QueryType
|
263
|
-
mutation: MutationType
|
264
|
-
}
|
265
|
-
GRAPHQL
|
266
|
-
}
|
267
|
-
|
268
|
-
let(:document) {
|
269
|
-
subject.new(
|
270
|
-
schema,
|
271
|
-
except: ->(m, _ctx) { m.is_a?(GraphQL::BaseType) && m.name == "Type" }
|
272
|
-
).document
|
273
|
-
}
|
274
|
-
|
275
|
-
it "returns the IDL minus the filtered members" do
|
276
|
-
assert equivalent_node?(expected_document, document)
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
describe "with an only filter" do
|
281
|
-
let(:expected_idl) { <<-GRAPHQL
|
282
|
-
type QueryType {
|
283
|
-
foo: Foo
|
284
|
-
}
|
285
|
-
|
286
|
-
type Foo implements Bar {
|
287
|
-
three(argument: InputType, other: String): CustomScalar
|
288
|
-
four(argument: String = "string"): String
|
289
|
-
five(argument: [String] = ["string", "string"]): Site
|
290
|
-
}
|
291
|
-
|
292
|
-
interface Bar {
|
293
|
-
one: Type
|
294
|
-
four(argument: String = "string"): String
|
295
|
-
}
|
296
|
-
|
297
|
-
input InputType {
|
298
|
-
key: String!
|
299
|
-
answer: Int = 42
|
300
|
-
}
|
301
|
-
|
302
|
-
type MutationType {
|
303
|
-
a(input: InputType): String
|
304
|
-
}
|
305
|
-
|
306
|
-
enum Site {
|
307
|
-
DESKTOP
|
308
|
-
MOBILE
|
309
|
-
}
|
310
|
-
|
311
|
-
schema {
|
312
|
-
query: QueryType
|
313
|
-
mutation: MutationType
|
314
|
-
}
|
315
|
-
GRAPHQL
|
316
|
-
}
|
317
|
-
|
318
|
-
let(:document) {
|
319
|
-
subject.new(
|
320
|
-
schema,
|
321
|
-
only: ->(m, _ctx) { !(m.is_a?(GraphQL::ScalarType) && m.name == "CustomScalar") }
|
322
|
-
).document
|
323
|
-
}
|
324
|
-
|
325
|
-
it "returns the IDL minus the filtered members" do
|
326
|
-
assert equivalent_node?(expected_document, document)
|
327
|
-
end
|
328
|
-
end
|
329
|
-
|
330
|
-
describe "when excluding built ins and introspection types" do
|
331
|
-
let(:expected_idl) { <<-GRAPHQL
|
332
|
-
type QueryType {
|
333
|
-
foo: Foo
|
334
|
-
}
|
335
|
-
|
336
|
-
type Foo implements Bar {
|
337
|
-
one: Type
|
338
|
-
two(argument: InputType!): Site
|
339
|
-
three(argument: InputType, other: String): CustomScalar
|
340
|
-
four(argument: String = "string"): String
|
341
|
-
five(argument: [String] = ["string", "string"]): String
|
342
|
-
six(argument: String): Type
|
343
|
-
}
|
344
|
-
|
345
|
-
interface Bar {
|
346
|
-
one: Type
|
347
|
-
four(argument: String = "string"): String
|
348
|
-
}
|
349
|
-
|
350
|
-
type Type {
|
351
|
-
a: String
|
352
|
-
}
|
353
|
-
|
354
|
-
input InputType {
|
355
|
-
key: String!
|
356
|
-
answer: Int = 42
|
357
|
-
}
|
358
|
-
|
359
|
-
type MutationType {
|
360
|
-
a(input: InputType): String
|
361
|
-
}
|
362
|
-
|
363
|
-
# Scalar description
|
364
|
-
scalar CustomScalar
|
365
|
-
|
366
|
-
enum Site {
|
367
|
-
DESKTOP
|
368
|
-
MOBILE
|
369
|
-
}
|
370
|
-
|
371
|
-
union Union = Type | QueryType
|
372
|
-
|
373
|
-
schema {
|
374
|
-
query: QueryType
|
375
|
-
mutation: MutationType
|
376
|
-
}
|
377
|
-
GRAPHQL
|
378
|
-
}
|
379
|
-
|
380
|
-
let(:document) {
|
381
|
-
subject.new(
|
382
|
-
schema,
|
383
|
-
always_include_schema: true
|
384
|
-
).document
|
385
|
-
}
|
386
|
-
|
387
|
-
it "returns the schema idl besides introspection types and built ins" do
|
388
|
-
assert equivalent_node?(expected_document, document)
|
389
|
-
end
|
390
|
-
end
|
391
|
-
|
392
|
-
describe "when printing excluding only introspection types" do
|
393
|
-
let(:expected_idl) { <<-GRAPHQL
|
394
|
-
# Represents `true` or `false` values.
|
395
|
-
scalar Boolean
|
396
|
-
|
397
|
-
# Represents textual data as UTF-8 character sequences. This type is most often
|
398
|
-
# used by GraphQL to represent free-form human-readable text.
|
399
|
-
scalar String
|
400
|
-
|
401
|
-
type QueryType {
|
402
|
-
foo: Foo
|
403
|
-
}
|
404
|
-
|
405
|
-
type Foo implements Bar {
|
406
|
-
one: Type
|
407
|
-
two(argument: InputType!): Type
|
408
|
-
three(argument: InputType, other: String): CustomScalar
|
409
|
-
four(argument: String = "string"): String
|
410
|
-
five(argument: [String] = ["string", "string"]): String
|
411
|
-
six(argument: String): Type
|
412
|
-
}
|
413
|
-
|
414
|
-
interface Bar {
|
415
|
-
one: Type
|
416
|
-
four(argument: String = "string"): String
|
417
|
-
}
|
418
|
-
|
419
|
-
type Type {
|
420
|
-
a: String
|
421
|
-
}
|
422
|
-
|
423
|
-
input InputType {
|
424
|
-
key: String!
|
425
|
-
answer: Int = 42
|
426
|
-
}
|
427
|
-
|
428
|
-
# Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
|
429
|
-
scalar Int
|
430
|
-
|
431
|
-
type MutationType {
|
432
|
-
a(input: InputType): String
|
433
|
-
}
|
434
|
-
|
435
|
-
# Represents signed double-precision fractional values as specified by [IEEE
|
436
|
-
# 754](https://en.wikipedia.org/wiki/IEEE_floating_point).
|
437
|
-
scalar Float
|
438
|
-
|
439
|
-
# Represents a unique identifier that is Base64 obfuscated. It is often used to
|
440
|
-
# refetch an object or as key for a cache. The ID type appears in a JSON response
|
441
|
-
# as a String; however, it is not intended to be human-readable. When expected as
|
442
|
-
# an input type, any string (such as `"VXNlci0xMA=="`) or integer (such as `4`)
|
443
|
-
# input value will be accepted as an ID.
|
444
|
-
scalar ID
|
445
|
-
|
446
|
-
# Scalar description
|
447
|
-
scalar CustomScalar
|
448
|
-
|
449
|
-
enum Site {
|
450
|
-
DESKTOP
|
451
|
-
MOBILE
|
452
|
-
}
|
453
|
-
|
454
|
-
union Union = Type | QueryType
|
455
|
-
|
456
|
-
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
|
457
|
-
|
458
|
-
directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
|
459
|
-
|
460
|
-
# Marks an element of a GraphQL schema as no longer supported.
|
461
|
-
directive @deprecated(reason: String = "No longer supported") on FIELD_DEFINITION | ENUM_VALUE
|
462
|
-
|
463
|
-
schema {
|
464
|
-
query: QueryType
|
465
|
-
mutation: MutationType
|
466
|
-
}
|
467
|
-
GRAPHQL
|
468
|
-
}
|
469
|
-
|
470
|
-
let(:document) {
|
471
|
-
subject.new(
|
472
|
-
schema,
|
473
|
-
include_built_in_scalars: true,
|
474
|
-
include_built_in_directives: true,
|
475
|
-
).document
|
476
|
-
}
|
477
|
-
|
478
|
-
it "returns the the schema IDL including only the built ins and not introspection types" do
|
479
|
-
assert equivalent_node?(expected_document, document)
|
480
|
-
end
|
481
|
-
end
|
482
|
-
|
483
|
-
describe "when printing the full schema" do
|
484
|
-
let(:expected_idl) { <<-GRAPHQL
|
485
|
-
# Represents `true` or `false` values.
|
486
|
-
scalar Boolean
|
487
|
-
|
488
|
-
# Represents textual data as UTF-8 character sequences. This type is most often
|
489
|
-
# used by GraphQL to represent free-form human-readable text.
|
490
|
-
scalar String
|
491
|
-
|
492
|
-
# The fundamental unit of any GraphQL Schema is the type. There are many kinds of
|
493
|
-
# types in GraphQL as represented by the `__TypeKind` enum.
|
494
|
-
#
|
495
|
-
# Depending on the kind of a type, certain fields describe information about that
|
496
|
-
# type. Scalar types provide no information beyond a name and description, while
|
497
|
-
# Enum types provide their values. Object and Interface types provide the fields
|
498
|
-
# they describe. Abstract types, Union and Interface, provide the Object types
|
499
|
-
# possible at runtime. List and NonNull types compose other types.
|
500
|
-
type __Type {
|
501
|
-
kind: __TypeKind!
|
502
|
-
name: String
|
503
|
-
description: String
|
504
|
-
fields(includeDeprecated: Boolean = false): [__Field!]
|
505
|
-
interfaces: [__Type!]
|
506
|
-
possibleTypes: [__Type!]
|
507
|
-
enumValues(includeDeprecated: Boolean = false): [__EnumValue!]
|
508
|
-
inputFields: [__InputValue!]
|
509
|
-
ofType: __Type
|
510
|
-
}
|
511
|
-
|
512
|
-
# An enum describing what kind of type a given `__Type` is.
|
513
|
-
enum __TypeKind {
|
514
|
-
# Indicates this type is a scalar.
|
515
|
-
SCALAR
|
516
|
-
|
517
|
-
# Indicates this type is an object. `fields` and `interfaces` are valid fields.
|
518
|
-
OBJECT
|
519
|
-
|
520
|
-
# Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.
|
521
|
-
INTERFACE
|
522
|
-
|
523
|
-
# Indicates this type is a union. `possibleTypes` is a valid field.
|
524
|
-
UNION
|
525
|
-
|
526
|
-
# Indicates this type is an enum. `enumValues` is a valid field.
|
527
|
-
ENUM
|
528
|
-
|
529
|
-
# Indicates this type is an input object. `inputFields` is a valid field.
|
530
|
-
INPUT_OBJECT
|
531
|
-
|
532
|
-
# Indicates this type is a list. `ofType` is a valid field.
|
533
|
-
LIST
|
534
|
-
|
535
|
-
# Indicates this type is a non-null. `ofType` is a valid field.
|
536
|
-
NON_NULL
|
537
|
-
}
|
538
|
-
|
539
|
-
# Object and Interface types are described by a list of Fields, each of which has
|
540
|
-
# a name, potentially a list of arguments, and a return type.
|
541
|
-
type __Field {
|
542
|
-
name: String!
|
543
|
-
description: String
|
544
|
-
args: [__InputValue!]!
|
545
|
-
type: __Type!
|
546
|
-
isDeprecated: Boolean!
|
547
|
-
deprecationReason: String
|
548
|
-
}
|
549
|
-
|
550
|
-
# Arguments provided to Fields or Directives and the input fields of an
|
551
|
-
# InputObject are represented as Input Values which describe their type and
|
552
|
-
# optionally a default value.
|
553
|
-
type __InputValue {
|
554
|
-
name: String!
|
555
|
-
description: String
|
556
|
-
type: __Type!
|
557
|
-
|
558
|
-
# A GraphQL-formatted string representing the default value for this input value.
|
559
|
-
defaultValue: String
|
560
|
-
}
|
561
|
-
|
562
|
-
# One possible value for a given Enum. Enum values are unique values, not a
|
563
|
-
# placeholder for a string or numeric value. However an Enum value is returned in
|
564
|
-
# a JSON response as a string.
|
565
|
-
type __EnumValue {
|
566
|
-
name: String!
|
567
|
-
description: String
|
568
|
-
isDeprecated: Boolean!
|
569
|
-
deprecationReason: String
|
570
|
-
}
|
571
|
-
|
572
|
-
type QueryType {
|
573
|
-
foo: Foo
|
574
|
-
}
|
575
|
-
|
576
|
-
type Foo implements Bar {
|
577
|
-
one: Type
|
578
|
-
two(argument: InputType!): Type
|
579
|
-
three(argument: InputType, other: String): Int
|
580
|
-
four(argument: String = "string"): String
|
581
|
-
five(argument: [String] = ["string", "string"]): String
|
582
|
-
six(argument: String): Type
|
583
|
-
}
|
584
|
-
|
585
|
-
interface Bar {
|
586
|
-
one: Type
|
587
|
-
four(argument: String = "string"): String
|
588
|
-
}
|
589
|
-
|
590
|
-
type Type {
|
591
|
-
a: String
|
592
|
-
}
|
593
|
-
|
594
|
-
input InputType {
|
595
|
-
key: String!
|
596
|
-
answer: Int = 42
|
597
|
-
}
|
598
|
-
|
599
|
-
# Represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.
|
600
|
-
scalar Int
|
601
|
-
|
602
|
-
type MutationType {
|
603
|
-
a(input: InputType): String
|
604
|
-
}
|
605
|
-
|
606
|
-
# A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all
|
607
|
-
# available types and directives on the server, as well as the entry points for
|
608
|
-
# query, mutation, and subscription operations.
|
609
|
-
type __Schema {
|
610
|
-
# A list of all types supported by this server.
|
611
|
-
types: [__Type!]!
|
612
|
-
|
613
|
-
# The type that query operations will be rooted at.
|
614
|
-
queryType: __Type!
|
615
|
-
|
616
|
-
# If this server supports mutation, the type that mutation operations will be rooted at.
|
617
|
-
mutationType: __Type
|
618
|
-
|
619
|
-
# If this server support subscription, the type that subscription operations will be rooted at.
|
620
|
-
subscriptionType: __Type
|
621
|
-
|
622
|
-
# A list of all directives supported by this server.
|
623
|
-
directives: [__Directive!]!
|
624
|
-
}
|
625
|
-
|
626
|
-
# A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
|
627
|
-
#
|
628
|
-
# In some cases, you need to provide options to alter GraphQL's execution behavior
|
629
|
-
# in ways field arguments will not suffice, such as conditionally including or
|
630
|
-
# skipping a field. Directives provide this by describing additional information
|
631
|
-
# to the executor.
|
632
|
-
type __Directive {
|
633
|
-
name: String!
|
634
|
-
description: String
|
635
|
-
locations: [__DirectiveLocation!]!
|
636
|
-
args: [__InputValue!]!
|
637
|
-
onOperation: Boolean!
|
638
|
-
onFragment: Boolean!
|
639
|
-
onField: Boolean!
|
640
|
-
}
|
641
|
-
|
642
|
-
# A Directive can be adjacent to many parts of the GraphQL language, a
|
643
|
-
# __DirectiveLocation describes one such possible adjacencies.
|
644
|
-
enum __DirectiveLocation {
|
645
|
-
# Location adjacent to a query operation.
|
646
|
-
QUERY
|
647
|
-
|
648
|
-
# Location adjacent to a mutation operation.
|
649
|
-
MUTATION
|
650
|
-
|
651
|
-
# Location adjacent to a subscription operation.
|
652
|
-
SUBSCRIPTION
|
653
|
-
|
654
|
-
# Location adjacent to a field.
|
655
|
-
FIELD
|
656
|
-
|
657
|
-
# Location adjacent to a fragment definition.
|
658
|
-
FRAGMENT_DEFINITION
|
659
|
-
|
660
|
-
# Location adjacent to a fragment spread.
|
661
|
-
FRAGMENT_SPREAD
|
662
|
-
|
663
|
-
# Location adjacent to an inline fragment.
|
664
|
-
INLINE_FRAGMENT
|
665
|
-
|
666
|
-
# Location adjacent to a schema definition.
|
667
|
-
SCHEMA
|
668
|
-
|
669
|
-
# Location adjacent to a scalar definition.
|
670
|
-
SCALAR
|
671
|
-
|
672
|
-
# Location adjacent to an object type definition.
|
673
|
-
OBJECT
|
674
|
-
|
675
|
-
# Location adjacent to a field definition.
|
676
|
-
FIELD_DEFINITION
|
677
|
-
|
678
|
-
# Location adjacent to an argument definition.
|
679
|
-
ARGUMENT_DEFINITION
|
680
|
-
|
681
|
-
# Location adjacent to an interface definition.
|
682
|
-
INTERFACE
|
683
|
-
|
684
|
-
# Location adjacent to a union definition.
|
685
|
-
UNION
|
686
|
-
|
687
|
-
# Location adjacent to an enum definition.
|
688
|
-
ENUM
|
689
|
-
|
690
|
-
# Location adjacent to an enum value definition.
|
691
|
-
ENUM_VALUE
|
692
|
-
|
693
|
-
# Location adjacent to an input object type definition.
|
694
|
-
INPUT_OBJECT
|
695
|
-
|
696
|
-
# Location adjacent to an input object field definition.
|
697
|
-
INPUT_FIELD_DEFINITION
|
698
|
-
}
|
699
|
-
|
700
|
-
# Represents signed double-precision fractional values as specified by [IEEE
|
701
|
-
# 754](https://en.wikipedia.org/wiki/IEEE_floating_point).
|
702
|
-
scalar Float
|
703
|
-
|
704
|
-
# Represents a unique identifier that is Base64 obfuscated. It is often used to
|
705
|
-
# refetch an object or as key for a cache. The ID type appears in a JSON response
|
706
|
-
# as a String; however, it is not intended to be human-readable. When expected as
|
707
|
-
# an input type, any string (such as `"VXNlci0xMA=="`) or integer (such as `4`)
|
708
|
-
# input value will be accepted as an ID.
|
709
|
-
scalar ID
|
710
|
-
|
711
|
-
# Scalar description
|
712
|
-
scalar CustomScalar
|
713
|
-
|
714
|
-
enum Site {
|
715
|
-
DESKTOP
|
716
|
-
MOBILE
|
717
|
-
}
|
718
|
-
|
719
|
-
union Union = Type | QueryType
|
720
|
-
|
721
|
-
directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
|
722
|
-
|
723
|
-
directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
|
724
|
-
|
725
|
-
# Marks an element of a GraphQL schema as no longer supported.
|
726
|
-
directive @deprecated(reason: String = "No longer supported") on FIELD_DEFINITION | ENUM_VALUE
|
727
|
-
|
728
|
-
schema {
|
729
|
-
query: QueryType
|
730
|
-
mutation: MutationType
|
731
|
-
}
|
732
|
-
GRAPHQL
|
733
|
-
}
|
734
|
-
|
735
|
-
let(:document) {
|
736
|
-
subject.new(
|
737
|
-
schema,
|
738
|
-
include_introspection_types: true,
|
739
|
-
include_built_in_directives: true,
|
740
|
-
include_built_in_scalars: true,
|
741
|
-
always_include_schema: true,
|
742
|
-
).document
|
743
|
-
}
|
744
|
-
|
745
|
-
it "returns the full document AST from the given schema including built ins and introspection" do
|
746
|
-
assert equivalent_node?(expected_document, document)
|
747
|
-
end
|
748
|
-
end
|
749
|
-
end
|
750
|
-
|
751
|
-
private
|
752
|
-
|
753
|
-
def equivalent_node?(expected, node)
|
754
|
-
return false unless expected.is_a?(node.class)
|
755
|
-
|
756
|
-
if expected.respond_to?(:children) && expected.respond_to?(:scalars)
|
757
|
-
children_equal = expected.children.all? do |expected_child|
|
758
|
-
node.children.find { |child| equivalent_node?(expected_child, child) }
|
759
|
-
end
|
760
|
-
|
761
|
-
scalars_equal = expected.children.all? do |expected_child|
|
762
|
-
node.children.find { |child| equivalent_node?(expected_child, child) }
|
763
|
-
end
|
764
|
-
|
765
|
-
children_equal && scalars_equal
|
766
|
-
else
|
767
|
-
expected == node
|
768
|
-
end
|
769
|
-
end
|
770
|
-
end
|