graphql 1.13.12 → 2.0.21
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/install_generator.rb +1 -1
- data/lib/generators/graphql/relay.rb +3 -17
- data/lib/generators/graphql/templates/schema.erb +3 -0
- data/lib/graphql/analysis/ast/field_usage.rb +3 -1
- data/lib/graphql/analysis/ast/max_query_complexity.rb +0 -1
- data/lib/graphql/analysis/ast/query_complexity.rb +1 -1
- data/lib/graphql/analysis/ast/query_depth.rb +0 -1
- data/lib/graphql/analysis/ast/visitor.rb +43 -36
- data/lib/graphql/analysis/ast.rb +2 -12
- data/lib/graphql/analysis.rb +0 -7
- data/lib/graphql/backtrace/table.rb +2 -20
- data/lib/graphql/backtrace/trace.rb +96 -0
- data/lib/graphql/backtrace/tracer.rb +2 -3
- data/lib/graphql/backtrace.rb +7 -8
- data/lib/graphql/dataloader/null_dataloader.rb +3 -1
- data/lib/graphql/dataloader/source.rb +9 -0
- data/lib/graphql/dataloader.rb +4 -1
- data/lib/graphql/dig.rb +1 -1
- data/lib/graphql/execution/errors.rb +12 -82
- data/lib/graphql/execution/interpreter/arguments.rb +1 -1
- data/lib/graphql/execution/interpreter/arguments_cache.rb +2 -3
- data/lib/graphql/execution/interpreter/resolve.rb +26 -0
- data/lib/graphql/execution/interpreter/runtime.rb +300 -222
- data/lib/graphql/execution/interpreter.rb +187 -78
- data/lib/graphql/execution/lazy.rb +7 -21
- data/lib/graphql/execution/lookahead.rb +44 -40
- data/lib/graphql/execution/multiplex.rb +3 -174
- data/lib/graphql/execution.rb +11 -4
- data/lib/graphql/filter.rb +7 -2
- data/lib/graphql/introspection/directive_type.rb +2 -2
- data/lib/graphql/introspection/dynamic_fields.rb +3 -8
- data/lib/graphql/introspection/entry_points.rb +2 -15
- data/lib/graphql/introspection/field_type.rb +1 -1
- data/lib/graphql/introspection/schema_type.rb +2 -2
- data/lib/graphql/introspection/type_type.rb +13 -6
- data/lib/graphql/introspection.rb +4 -3
- data/lib/graphql/language/document_from_schema_definition.rb +43 -44
- data/lib/graphql/language/lexer.rb +216 -1488
- data/lib/graphql/language/nodes.rb +66 -40
- data/lib/graphql/language/parser.rb +539 -510
- data/lib/graphql/language/parser.y +53 -44
- data/lib/graphql/language/printer.rb +37 -21
- data/lib/graphql/language/visitor.rb +191 -83
- data/lib/graphql/pagination/active_record_relation_connection.rb +0 -8
- data/lib/graphql/pagination/array_connection.rb +4 -2
- data/lib/graphql/pagination/connection.rb +33 -6
- data/lib/graphql/pagination/connections.rb +3 -28
- data/lib/graphql/pagination/relation_connection.rb +2 -0
- data/lib/graphql/query/context.rb +156 -196
- data/lib/graphql/query/input_validation_result.rb +10 -1
- data/lib/graphql/query/null_context.rb +1 -4
- data/lib/graphql/query/validation_pipeline.rb +12 -37
- data/lib/graphql/query/variable_validation_error.rb +2 -2
- data/lib/graphql/query/variables.rb +35 -21
- data/lib/graphql/query.rb +39 -46
- data/lib/graphql/railtie.rb +0 -104
- data/lib/graphql/rake_task/validate.rb +1 -1
- data/lib/graphql/rake_task.rb +29 -1
- data/lib/graphql/relay/range_add.rb +9 -20
- data/lib/graphql/relay.rb +0 -15
- data/lib/graphql/schema/addition.rb +7 -9
- data/lib/graphql/schema/argument.rb +38 -47
- data/lib/graphql/schema/build_from_definition.rb +47 -21
- data/lib/graphql/schema/directive/one_of.rb +12 -0
- data/lib/graphql/schema/directive/transform.rb +1 -1
- data/lib/graphql/schema/directive.rb +12 -23
- data/lib/graphql/schema/enum.rb +29 -41
- data/lib/graphql/schema/enum_value.rb +2 -25
- data/lib/graphql/schema/field/connection_extension.rb +4 -0
- data/lib/graphql/schema/field.rb +256 -349
- data/lib/graphql/schema/field_extension.rb +1 -4
- data/lib/graphql/schema/find_inherited_value.rb +2 -7
- data/lib/graphql/schema/input_object.rb +57 -69
- data/lib/graphql/schema/interface.rb +0 -35
- data/lib/graphql/schema/introspection_system.rb +3 -8
- data/lib/graphql/schema/late_bound_type.rb +8 -2
- data/lib/graphql/schema/list.rb +18 -9
- data/lib/graphql/schema/loader.rb +1 -2
- data/lib/graphql/schema/member/base_dsl_methods.rb +17 -19
- data/lib/graphql/schema/member/build_type.rb +5 -7
- data/lib/graphql/schema/member/has_arguments.rb +147 -56
- data/lib/graphql/schema/member/has_ast_node.rb +12 -0
- data/lib/graphql/schema/member/has_deprecation_reason.rb +3 -4
- data/lib/graphql/schema/member/has_directives.rb +81 -61
- data/lib/graphql/schema/member/has_fields.rb +97 -40
- data/lib/graphql/schema/member/has_interfaces.rb +49 -10
- data/lib/graphql/schema/member/has_validators.rb +32 -6
- data/lib/graphql/schema/member/relay_shortcuts.rb +47 -2
- data/lib/graphql/schema/member/type_system_helpers.rb +17 -0
- data/lib/graphql/schema/member/validates_input.rb +3 -3
- data/lib/graphql/schema/member.rb +0 -6
- data/lib/graphql/schema/mutation.rb +0 -9
- data/lib/graphql/schema/non_null.rb +3 -9
- data/lib/graphql/schema/object.rb +15 -52
- data/lib/graphql/schema/relay_classic_mutation.rb +53 -42
- data/lib/graphql/schema/resolver/has_payload_type.rb +20 -10
- data/lib/graphql/schema/resolver.rb +43 -44
- data/lib/graphql/schema/scalar.rb +8 -23
- data/lib/graphql/schema/subscription.rb +0 -7
- data/lib/graphql/schema/timeout.rb +24 -28
- data/lib/graphql/schema/type_membership.rb +3 -0
- data/lib/graphql/schema/union.rb +10 -17
- data/lib/graphql/schema/validator.rb +1 -1
- data/lib/graphql/schema/warden.rb +37 -9
- data/lib/graphql/schema/wrapper.rb +0 -5
- data/lib/graphql/schema.rb +265 -968
- data/lib/graphql/static_validation/all_rules.rb +1 -0
- data/lib/graphql/static_validation/base_visitor.rb +4 -21
- data/lib/graphql/static_validation/definition_dependencies.rb +7 -1
- data/lib/graphql/static_validation/error.rb +2 -2
- data/lib/graphql/static_validation/literal_validator.rb +19 -1
- data/lib/graphql/static_validation/rules/directives_are_defined.rb +11 -5
- data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +12 -12
- data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +12 -4
- data/lib/graphql/static_validation/rules/fields_will_merge.rb +2 -2
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +66 -0
- data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +29 -0
- data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +12 -6
- data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +1 -1
- data/lib/graphql/static_validation/validator.rb +3 -25
- data/lib/graphql/static_validation.rb +0 -2
- data/lib/graphql/subscriptions/action_cable_subscriptions.rb +7 -1
- data/lib/graphql/subscriptions/default_subscription_resolve_extension.rb +38 -1
- data/lib/graphql/subscriptions/event.rb +3 -8
- data/lib/graphql/subscriptions/instrumentation.rb +0 -51
- data/lib/graphql/subscriptions.rb +32 -20
- data/lib/graphql/tracing/active_support_notifications_trace.rb +16 -0
- data/lib/graphql/tracing/appoptics_trace.rb +231 -0
- data/lib/graphql/tracing/appsignal_trace.rb +77 -0
- data/lib/graphql/tracing/data_dog_trace.rb +148 -0
- data/lib/graphql/tracing/data_dog_tracing.rb +21 -2
- data/lib/graphql/tracing/legacy_trace.rb +65 -0
- data/lib/graphql/tracing/new_relic_trace.rb +75 -0
- data/lib/graphql/tracing/notifications_trace.rb +42 -0
- data/lib/graphql/tracing/platform_trace.rb +109 -0
- data/lib/graphql/tracing/platform_tracing.rb +33 -43
- data/lib/graphql/tracing/prometheus_trace.rb +89 -0
- data/lib/graphql/tracing/prometheus_tracing/graphql_collector.rb +1 -1
- data/lib/graphql/tracing/prometheus_tracing.rb +3 -3
- data/lib/graphql/tracing/scout_trace.rb +72 -0
- data/lib/graphql/tracing/statsd_trace.rb +56 -0
- data/lib/graphql/tracing/trace.rb +75 -0
- data/lib/graphql/tracing.rb +16 -40
- data/lib/graphql/type_kinds.rb +6 -3
- data/lib/graphql/types/iso_8601_date.rb +4 -1
- data/lib/graphql/types/iso_8601_date_time.rb +4 -0
- data/lib/graphql/types/relay/base_connection.rb +16 -6
- data/lib/graphql/types/relay/connection_behaviors.rb +29 -27
- data/lib/graphql/types/relay/edge_behaviors.rb +16 -5
- data/lib/graphql/types/relay/node_behaviors.rb +12 -2
- data/lib/graphql/types/relay/page_info_behaviors.rb +7 -2
- data/lib/graphql/types/relay.rb +0 -3
- data/lib/graphql/types/string.rb +1 -1
- data/lib/graphql/version.rb +1 -1
- data/lib/graphql.rb +17 -74
- metadata +33 -133
- data/lib/graphql/analysis/analyze_query.rb +0 -98
- data/lib/graphql/analysis/field_usage.rb +0 -45
- data/lib/graphql/analysis/max_query_complexity.rb +0 -26
- data/lib/graphql/analysis/max_query_depth.rb +0 -26
- data/lib/graphql/analysis/query_complexity.rb +0 -88
- data/lib/graphql/analysis/query_depth.rb +0 -43
- data/lib/graphql/analysis/reducer_state.rb +0 -48
- data/lib/graphql/argument.rb +0 -131
- data/lib/graphql/authorization.rb +0 -82
- data/lib/graphql/backtrace/legacy_tracer.rb +0 -56
- data/lib/graphql/backwards_compatibility.rb +0 -61
- data/lib/graphql/base_type.rb +0 -232
- data/lib/graphql/boolean_type.rb +0 -2
- data/lib/graphql/compatibility/execution_specification/counter_schema.rb +0 -53
- data/lib/graphql/compatibility/execution_specification/specification_schema.rb +0 -200
- data/lib/graphql/compatibility/execution_specification.rb +0 -436
- data/lib/graphql/compatibility/lazy_execution_specification/lazy_schema.rb +0 -111
- data/lib/graphql/compatibility/lazy_execution_specification.rb +0 -215
- data/lib/graphql/compatibility/query_parser_specification/parse_error_specification.rb +0 -87
- data/lib/graphql/compatibility/query_parser_specification/query_assertions.rb +0 -79
- data/lib/graphql/compatibility/query_parser_specification.rb +0 -266
- data/lib/graphql/compatibility/schema_parser_specification.rb +0 -682
- data/lib/graphql/compatibility.rb +0 -5
- data/lib/graphql/define/assign_argument.rb +0 -12
- data/lib/graphql/define/assign_connection.rb +0 -13
- data/lib/graphql/define/assign_enum_value.rb +0 -18
- data/lib/graphql/define/assign_global_id_field.rb +0 -11
- data/lib/graphql/define/assign_mutation_function.rb +0 -34
- data/lib/graphql/define/assign_object_field.rb +0 -42
- data/lib/graphql/define/defined_object_proxy.rb +0 -53
- data/lib/graphql/define/instance_definable.rb +0 -255
- data/lib/graphql/define/no_definition_error.rb +0 -7
- data/lib/graphql/define/non_null_with_bang.rb +0 -16
- data/lib/graphql/define/type_definer.rb +0 -31
- data/lib/graphql/define.rb +0 -31
- data/lib/graphql/deprecated_dsl.rb +0 -55
- data/lib/graphql/directive/deprecated_directive.rb +0 -2
- data/lib/graphql/directive/include_directive.rb +0 -2
- data/lib/graphql/directive/skip_directive.rb +0 -2
- data/lib/graphql/directive.rb +0 -107
- data/lib/graphql/enum_type.rb +0 -133
- data/lib/graphql/execution/execute.rb +0 -333
- data/lib/graphql/execution/flatten.rb +0 -40
- data/lib/graphql/execution/instrumentation.rb +0 -92
- data/lib/graphql/execution/lazy/resolve.rb +0 -91
- data/lib/graphql/execution/typecast.rb +0 -50
- data/lib/graphql/field/resolve.rb +0 -59
- data/lib/graphql/field.rb +0 -226
- data/lib/graphql/float_type.rb +0 -2
- data/lib/graphql/function.rb +0 -128
- data/lib/graphql/id_type.rb +0 -2
- data/lib/graphql/input_object_type.rb +0 -138
- data/lib/graphql/int_type.rb +0 -2
- data/lib/graphql/interface_type.rb +0 -72
- data/lib/graphql/internal_representation/document.rb +0 -27
- data/lib/graphql/internal_representation/node.rb +0 -206
- data/lib/graphql/internal_representation/print.rb +0 -51
- data/lib/graphql/internal_representation/rewrite.rb +0 -184
- data/lib/graphql/internal_representation/scope.rb +0 -88
- data/lib/graphql/internal_representation/visit.rb +0 -36
- data/lib/graphql/internal_representation.rb +0 -7
- data/lib/graphql/language/lexer.rl +0 -260
- data/lib/graphql/list_type.rb +0 -80
- data/lib/graphql/non_null_type.rb +0 -71
- data/lib/graphql/object_type.rb +0 -130
- data/lib/graphql/query/arguments.rb +0 -189
- data/lib/graphql/query/arguments_cache.rb +0 -24
- data/lib/graphql/query/executor.rb +0 -52
- data/lib/graphql/query/literal_input.rb +0 -136
- data/lib/graphql/query/serial_execution/field_resolution.rb +0 -92
- data/lib/graphql/query/serial_execution/operation_resolution.rb +0 -19
- data/lib/graphql/query/serial_execution/selection_resolution.rb +0 -23
- data/lib/graphql/query/serial_execution/value_resolution.rb +0 -87
- data/lib/graphql/query/serial_execution.rb +0 -40
- data/lib/graphql/relay/array_connection.rb +0 -83
- data/lib/graphql/relay/base_connection.rb +0 -189
- data/lib/graphql/relay/connection_instrumentation.rb +0 -54
- data/lib/graphql/relay/connection_resolve.rb +0 -43
- data/lib/graphql/relay/connection_type.rb +0 -54
- data/lib/graphql/relay/edge.rb +0 -27
- data/lib/graphql/relay/edge_type.rb +0 -19
- data/lib/graphql/relay/edges_instrumentation.rb +0 -39
- data/lib/graphql/relay/global_id_resolve.rb +0 -17
- data/lib/graphql/relay/mongo_relation_connection.rb +0 -50
- data/lib/graphql/relay/mutation/instrumentation.rb +0 -23
- data/lib/graphql/relay/mutation/resolve.rb +0 -56
- data/lib/graphql/relay/mutation/result.rb +0 -38
- data/lib/graphql/relay/mutation.rb +0 -106
- data/lib/graphql/relay/node.rb +0 -39
- data/lib/graphql/relay/page_info.rb +0 -7
- data/lib/graphql/relay/relation_connection.rb +0 -188
- data/lib/graphql/relay/type_extensions.rb +0 -32
- data/lib/graphql/scalar_type.rb +0 -91
- data/lib/graphql/schema/catchall_middleware.rb +0 -35
- data/lib/graphql/schema/default_parse_error.rb +0 -10
- data/lib/graphql/schema/default_type_error.rb +0 -17
- data/lib/graphql/schema/member/accepts_definition.rb +0 -164
- data/lib/graphql/schema/member/cached_graphql_definition.rb +0 -58
- data/lib/graphql/schema/member/instrumentation.rb +0 -131
- data/lib/graphql/schema/middleware_chain.rb +0 -82
- data/lib/graphql/schema/possible_types.rb +0 -44
- data/lib/graphql/schema/rescue_middleware.rb +0 -60
- data/lib/graphql/schema/timeout_middleware.rb +0 -88
- data/lib/graphql/schema/traversal.rb +0 -228
- data/lib/graphql/schema/validation.rb +0 -313
- data/lib/graphql/static_validation/default_visitor.rb +0 -15
- data/lib/graphql/static_validation/no_validate_visitor.rb +0 -10
- data/lib/graphql/string_type.rb +0 -2
- data/lib/graphql/subscriptions/subscription_root.rb +0 -76
- data/lib/graphql/tracing/skylight_tracing.rb +0 -70
- data/lib/graphql/types/relay/default_relay.rb +0 -31
- data/lib/graphql/types/relay/node_field.rb +0 -24
- data/lib/graphql/types/relay/nodes_field.rb +0 -43
- data/lib/graphql/union_type.rb +0 -115
- data/lib/graphql/upgrader/member.rb +0 -937
- data/lib/graphql/upgrader/schema.rb +0 -38
@@ -1,260 +0,0 @@
|
|
1
|
-
%%{
|
2
|
-
machine graphql_lexer;
|
3
|
-
|
4
|
-
IDENTIFIER = [_A-Za-z][_0-9A-Za-z]*;
|
5
|
-
NEWLINE = [\c\r\n];
|
6
|
-
BLANK = [, \t]+;
|
7
|
-
COMMENT = '#' [^\n\r]*;
|
8
|
-
INT = '-'? ('0'|[1-9][0-9]*);
|
9
|
-
FLOAT_DECIMAL = '.'[0-9]+;
|
10
|
-
FLOAT_EXP = ('e' | 'E')?('+' | '-')?[0-9]+;
|
11
|
-
FLOAT = INT FLOAT_DECIMAL? FLOAT_EXP?;
|
12
|
-
ON = 'on';
|
13
|
-
FRAGMENT = 'fragment';
|
14
|
-
TRUE = 'true';
|
15
|
-
FALSE = 'false';
|
16
|
-
NULL = 'null';
|
17
|
-
QUERY = 'query';
|
18
|
-
MUTATION = 'mutation';
|
19
|
-
SUBSCRIPTION = 'subscription';
|
20
|
-
SCHEMA = 'schema';
|
21
|
-
SCALAR = 'scalar';
|
22
|
-
TYPE = 'type';
|
23
|
-
EXTEND = 'extend';
|
24
|
-
IMPLEMENTS = 'implements';
|
25
|
-
INTERFACE = 'interface';
|
26
|
-
UNION = 'union';
|
27
|
-
ENUM = 'enum';
|
28
|
-
INPUT = 'input';
|
29
|
-
DIRECTIVE = 'directive';
|
30
|
-
REPEATABLE = 'repeatable';
|
31
|
-
LCURLY = '{';
|
32
|
-
RCURLY = '}';
|
33
|
-
LPAREN = '(';
|
34
|
-
RPAREN = ')';
|
35
|
-
LBRACKET = '[';
|
36
|
-
RBRACKET = ']';
|
37
|
-
COLON = ':';
|
38
|
-
QUOTE = '"';
|
39
|
-
BACKSLASH = '\\';
|
40
|
-
# Could limit to hex here, but “bad unicode escape” on 0XXF is probably a
|
41
|
-
# more helpful error than “unknown char”
|
42
|
-
UNICODE_ESCAPE = '\\u' [0-9A-Za-z]{4};
|
43
|
-
# https://graphql.github.io/graphql-spec/June2018/#sec-String-Value
|
44
|
-
STRING_ESCAPE = '\\' [\\/bfnrt];
|
45
|
-
BLOCK_QUOTE = '"""';
|
46
|
-
ESCAPED_BLOCK_QUOTE = '\\"""';
|
47
|
-
BLOCK_STRING_CHAR = (ESCAPED_BLOCK_QUOTE | ^QUOTE | QUOTE{1,2} ^QUOTE);
|
48
|
-
ESCAPED_QUOTE = '\\"';
|
49
|
-
STRING_CHAR = ((ESCAPED_QUOTE | ^QUOTE) - BACKSLASH) | UNICODE_ESCAPE | STRING_ESCAPE;
|
50
|
-
VAR_SIGN = '$';
|
51
|
-
DIR_SIGN = '@';
|
52
|
-
ELLIPSIS = '...';
|
53
|
-
EQUALS = '=';
|
54
|
-
BANG = '!';
|
55
|
-
PIPE = '|';
|
56
|
-
AMP = '&';
|
57
|
-
|
58
|
-
QUOTED_STRING = QUOTE STRING_CHAR* QUOTE;
|
59
|
-
BLOCK_STRING = BLOCK_QUOTE BLOCK_STRING_CHAR* QUOTE{0,2} BLOCK_QUOTE;
|
60
|
-
# catch-all for anything else. must be at the bottom for precedence.
|
61
|
-
UNKNOWN_CHAR = /./;
|
62
|
-
|
63
|
-
# Used with ragel -V for graphviz visualization
|
64
|
-
str := |*
|
65
|
-
QUOTED_STRING => { emit_string(ts, te, meta, block: false) };
|
66
|
-
*|;
|
67
|
-
|
68
|
-
main := |*
|
69
|
-
INT => { emit(:INT, ts, te, meta) };
|
70
|
-
FLOAT => { emit(:FLOAT, ts, te, meta) };
|
71
|
-
ON => { emit(:ON, ts, te, meta, "on") };
|
72
|
-
FRAGMENT => { emit(:FRAGMENT, ts, te, meta, "fragment") };
|
73
|
-
TRUE => { emit(:TRUE, ts, te, meta, "true") };
|
74
|
-
FALSE => { emit(:FALSE, ts, te, meta, "false") };
|
75
|
-
NULL => { emit(:NULL, ts, te, meta, "null") };
|
76
|
-
QUERY => { emit(:QUERY, ts, te, meta, "query") };
|
77
|
-
MUTATION => { emit(:MUTATION, ts, te, meta, "mutation") };
|
78
|
-
SUBSCRIPTION => { emit(:SUBSCRIPTION, ts, te, meta, "subscription") };
|
79
|
-
SCHEMA => { emit(:SCHEMA, ts, te, meta) };
|
80
|
-
SCALAR => { emit(:SCALAR, ts, te, meta) };
|
81
|
-
TYPE => { emit(:TYPE, ts, te, meta) };
|
82
|
-
EXTEND => { emit(:EXTEND, ts, te, meta) };
|
83
|
-
IMPLEMENTS => { emit(:IMPLEMENTS, ts, te, meta) };
|
84
|
-
INTERFACE => { emit(:INTERFACE, ts, te, meta) };
|
85
|
-
UNION => { emit(:UNION, ts, te, meta) };
|
86
|
-
ENUM => { emit(:ENUM, ts, te, meta) };
|
87
|
-
INPUT => { emit(:INPUT, ts, te, meta) };
|
88
|
-
DIRECTIVE => { emit(:DIRECTIVE, ts, te, meta) };
|
89
|
-
REPEATABLE => { emit(:REPEATABLE, ts, te, meta, "repeatable") };
|
90
|
-
RCURLY => { emit(:RCURLY, ts, te, meta, "}") };
|
91
|
-
LCURLY => { emit(:LCURLY, ts, te, meta, "{") };
|
92
|
-
RPAREN => { emit(:RPAREN, ts, te, meta, ")") };
|
93
|
-
LPAREN => { emit(:LPAREN, ts, te, meta, "(")};
|
94
|
-
RBRACKET => { emit(:RBRACKET, ts, te, meta, "]") };
|
95
|
-
LBRACKET => { emit(:LBRACKET, ts, te, meta, "[") };
|
96
|
-
COLON => { emit(:COLON, ts, te, meta, ":") };
|
97
|
-
QUOTED_STRING => { emit_string(ts, te, meta, block: false) };
|
98
|
-
BLOCK_STRING => { emit_string(ts, te, meta, block: true) };
|
99
|
-
VAR_SIGN => { emit(:VAR_SIGN, ts, te, meta, "$") };
|
100
|
-
DIR_SIGN => { emit(:DIR_SIGN, ts, te, meta, "@") };
|
101
|
-
ELLIPSIS => { emit(:ELLIPSIS, ts, te, meta, "...") };
|
102
|
-
EQUALS => { emit(:EQUALS, ts, te, meta, "=") };
|
103
|
-
BANG => { emit(:BANG, ts, te, meta, "!") };
|
104
|
-
PIPE => { emit(:PIPE, ts, te, meta, "|") };
|
105
|
-
AMP => { emit(:AMP, ts, te, meta, "&") };
|
106
|
-
IDENTIFIER => { emit(:IDENTIFIER, ts, te, meta) };
|
107
|
-
COMMENT => { record_comment(ts, te, meta) };
|
108
|
-
|
109
|
-
NEWLINE => {
|
110
|
-
meta[:line] += 1
|
111
|
-
meta[:col] = 1
|
112
|
-
};
|
113
|
-
|
114
|
-
BLANK => { meta[:col] += te - ts };
|
115
|
-
|
116
|
-
UNKNOWN_CHAR => { emit(:UNKNOWN_CHAR, ts, te, meta) };
|
117
|
-
|
118
|
-
*|;
|
119
|
-
}%%
|
120
|
-
|
121
|
-
# frozen_string_literal: true
|
122
|
-
|
123
|
-
module GraphQL
|
124
|
-
module Language
|
125
|
-
module Lexer
|
126
|
-
def self.tokenize(query_string)
|
127
|
-
run_lexer(query_string)
|
128
|
-
end
|
129
|
-
|
130
|
-
# Replace any escaped unicode or whitespace with the _actual_ characters
|
131
|
-
# To avoid allocating more strings, this modifies the string passed into it
|
132
|
-
def self.replace_escaped_characters_in_place(raw_string)
|
133
|
-
raw_string.gsub!(ESCAPES, ESCAPES_REPLACE)
|
134
|
-
raw_string.gsub!(UTF_8, &UTF_8_REPLACE)
|
135
|
-
nil
|
136
|
-
end
|
137
|
-
|
138
|
-
private
|
139
|
-
|
140
|
-
%% write data;
|
141
|
-
|
142
|
-
def self.run_lexer(query_string)
|
143
|
-
data = query_string.unpack(PACK_DIRECTIVE)
|
144
|
-
eof = data.length
|
145
|
-
|
146
|
-
# Since `Lexer` is a module, store all lexer state
|
147
|
-
# in this local variable:
|
148
|
-
meta = {
|
149
|
-
line: 1,
|
150
|
-
col: 1,
|
151
|
-
data: data,
|
152
|
-
tokens: [],
|
153
|
-
previous_token: nil,
|
154
|
-
}
|
155
|
-
|
156
|
-
p ||= 0
|
157
|
-
pe ||= data.length
|
158
|
-
|
159
|
-
%% write init;
|
160
|
-
|
161
|
-
%% write exec;
|
162
|
-
|
163
|
-
meta[:tokens]
|
164
|
-
end
|
165
|
-
|
166
|
-
def self.record_comment(ts, te, meta)
|
167
|
-
token = GraphQL::Language::Token.new(
|
168
|
-
:COMMENT,
|
169
|
-
meta[:data][ts, te - ts].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING),
|
170
|
-
meta[:line],
|
171
|
-
meta[:col],
|
172
|
-
meta[:previous_token],
|
173
|
-
)
|
174
|
-
|
175
|
-
meta[:previous_token] = token
|
176
|
-
|
177
|
-
meta[:col] += te - ts
|
178
|
-
end
|
179
|
-
|
180
|
-
def self.emit(token_name, ts, te, meta, token_value = nil)
|
181
|
-
token_value ||= meta[:data][ts, te - ts].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING)
|
182
|
-
meta[:tokens] << token = GraphQL::Language::Token.new(
|
183
|
-
token_name,
|
184
|
-
token_value,
|
185
|
-
meta[:line],
|
186
|
-
meta[:col],
|
187
|
-
meta[:previous_token],
|
188
|
-
)
|
189
|
-
meta[:previous_token] = token
|
190
|
-
# Bump the column counter for the next token
|
191
|
-
meta[:col] += te - ts
|
192
|
-
end
|
193
|
-
|
194
|
-
ESCAPES = /\\["\\\/bfnrt]/
|
195
|
-
ESCAPES_REPLACE = {
|
196
|
-
'\\"' => '"',
|
197
|
-
"\\\\" => "\\",
|
198
|
-
"\\/" => '/',
|
199
|
-
"\\b" => "\b",
|
200
|
-
"\\f" => "\f",
|
201
|
-
"\\n" => "\n",
|
202
|
-
"\\r" => "\r",
|
203
|
-
"\\t" => "\t",
|
204
|
-
}
|
205
|
-
|
206
|
-
UTF_8 = /\\u[\dAa-f]{4}/i
|
207
|
-
UTF_8_REPLACE = ->(m) { [m[-4..-1].to_i(16)].pack('U'.freeze) }
|
208
|
-
|
209
|
-
VALID_STRING = /\A(?:[^\\]|#{ESCAPES}|#{UTF_8})*\z/o
|
210
|
-
|
211
|
-
PACK_DIRECTIVE = "c*"
|
212
|
-
UTF_8_ENCODING = "UTF-8"
|
213
|
-
|
214
|
-
def self.emit_string(ts, te, meta, block:)
|
215
|
-
quotes_length = block ? 3 : 1
|
216
|
-
value = meta[:data][ts + quotes_length, te - ts - 2 * quotes_length].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING) || ''
|
217
|
-
line_incr = 0
|
218
|
-
if block && !value.empty?
|
219
|
-
line_incr = value.count("\n")
|
220
|
-
value = GraphQL::Language::BlockString.trim_whitespace(value)
|
221
|
-
end
|
222
|
-
# TODO: replace with `String#match?` when we support only Ruby 2.4+
|
223
|
-
# (It's faster: https://bugs.ruby-lang.org/issues/8110)
|
224
|
-
if !value.valid_encoding? || !value.match?(VALID_STRING)
|
225
|
-
meta[:tokens] << token = GraphQL::Language::Token.new(
|
226
|
-
:BAD_UNICODE_ESCAPE,
|
227
|
-
value,
|
228
|
-
meta[:line],
|
229
|
-
meta[:col],
|
230
|
-
meta[:previous_token],
|
231
|
-
)
|
232
|
-
else
|
233
|
-
replace_escaped_characters_in_place(value)
|
234
|
-
|
235
|
-
if !value.valid_encoding?
|
236
|
-
meta[:tokens] << token = GraphQL::Language::Token.new(
|
237
|
-
:BAD_UNICODE_ESCAPE,
|
238
|
-
value,
|
239
|
-
meta[:line],
|
240
|
-
meta[:col],
|
241
|
-
meta[:previous_token],
|
242
|
-
)
|
243
|
-
else
|
244
|
-
meta[:tokens] << token = GraphQL::Language::Token.new(
|
245
|
-
:STRING,
|
246
|
-
value,
|
247
|
-
meta[:line],
|
248
|
-
meta[:col],
|
249
|
-
meta[:previous_token],
|
250
|
-
)
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
meta[:previous_token] = token
|
255
|
-
meta[:col] += te - ts
|
256
|
-
meta[:line] += line_incr
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
end
|
data/lib/graphql/list_type.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
# A list type modifies another type.
|
4
|
-
#
|
5
|
-
# List types can be created with the type helper (`types[InnerType]`)
|
6
|
-
# or {BaseType#to_list_type} (`InnerType.to_list_type`)
|
7
|
-
#
|
8
|
-
# For return types, it says that the returned value will be a list of the modified.
|
9
|
-
#
|
10
|
-
# @example A field which returns a list of items
|
11
|
-
# field :items, types[ItemType]
|
12
|
-
# # or
|
13
|
-
# field :items, ItemType.to_list_type
|
14
|
-
#
|
15
|
-
# For input types, it says that the incoming value will be a list of the modified type.
|
16
|
-
#
|
17
|
-
# @example A field which accepts a list of strings
|
18
|
-
# field :newNames do
|
19
|
-
# # ...
|
20
|
-
# argument :values, types[types.String]
|
21
|
-
# # or
|
22
|
-
# argument :values, types.String.to_list_type
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
# Given a list type, you can always get the underlying type with {#unwrap}.
|
26
|
-
#
|
27
|
-
class ListType < GraphQL::BaseType
|
28
|
-
include GraphQL::BaseType::ModifiesAnotherType
|
29
|
-
attr_reader :of_type
|
30
|
-
def initialize(of_type:)
|
31
|
-
super()
|
32
|
-
@of_type = of_type
|
33
|
-
end
|
34
|
-
|
35
|
-
def kind
|
36
|
-
GraphQL::TypeKinds::LIST
|
37
|
-
end
|
38
|
-
|
39
|
-
def to_s
|
40
|
-
"[#{of_type.to_s}]"
|
41
|
-
end
|
42
|
-
alias_method :inspect, :to_s
|
43
|
-
alias :to_type_signature :to_s
|
44
|
-
|
45
|
-
def coerce_result(value, ctx = nil)
|
46
|
-
if ctx.nil?
|
47
|
-
warn_deprecated_coerce("coerce_isolated_result")
|
48
|
-
ctx = GraphQL::Query::NullContext
|
49
|
-
end
|
50
|
-
ensure_array(value).map { |item| item.nil? ? nil : of_type.coerce_result(item, ctx) }
|
51
|
-
end
|
52
|
-
|
53
|
-
def list?
|
54
|
-
true
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
def coerce_non_null_input(value, ctx)
|
60
|
-
ensure_array(value).map { |item| of_type.coerce_input(item, ctx) }
|
61
|
-
end
|
62
|
-
|
63
|
-
def validate_non_null_input(value, ctx)
|
64
|
-
result = GraphQL::Query::InputValidationResult.new
|
65
|
-
|
66
|
-
ensure_array(value).each_with_index do |item, index|
|
67
|
-
item_result = of_type.validate_input(item, ctx)
|
68
|
-
if !item_result.valid?
|
69
|
-
result.merge_result!(index, item_result)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
result
|
74
|
-
end
|
75
|
-
|
76
|
-
def ensure_array(value)
|
77
|
-
value.is_a?(Array) ? value : [value]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
# A non-null type modifies another type.
|
4
|
-
#
|
5
|
-
# Non-null types can be created with `!` (`InnerType!`)
|
6
|
-
# or {BaseType#to_non_null_type} (`InnerType.to_non_null_type`)
|
7
|
-
#
|
8
|
-
# For return types, it says that the returned value will _always_ be present.
|
9
|
-
#
|
10
|
-
# @example A field which _always_ returns an error
|
11
|
-
# field :items, !ItemType
|
12
|
-
# # or
|
13
|
-
# field :items, ItemType.to_non_null_type
|
14
|
-
#
|
15
|
-
# (If the application fails to return a value, {InvalidNullError} will be passed to {Schema#type_error}.)
|
16
|
-
#
|
17
|
-
# For input types, it says that the incoming value _must_ be provided by the query.
|
18
|
-
#
|
19
|
-
# @example A field which _requires_ a string input
|
20
|
-
# field :newNames do
|
21
|
-
# # ...
|
22
|
-
# argument :values, !types.String
|
23
|
-
# # or
|
24
|
-
# argument :values, types.String.to_non_null_type
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
# (If a value isn't provided, {Query::VariableValidationError} will be raised).
|
28
|
-
#
|
29
|
-
# Given a non-null type, you can always get the underlying type with {#unwrap}.
|
30
|
-
#
|
31
|
-
class NonNullType < GraphQL::BaseType
|
32
|
-
include GraphQL::BaseType::ModifiesAnotherType
|
33
|
-
extend Forwardable
|
34
|
-
|
35
|
-
attr_reader :of_type
|
36
|
-
def initialize(of_type:)
|
37
|
-
super()
|
38
|
-
@of_type = of_type
|
39
|
-
end
|
40
|
-
|
41
|
-
def valid_input?(value, ctx)
|
42
|
-
validate_input(value, ctx).valid?
|
43
|
-
end
|
44
|
-
|
45
|
-
def validate_input(value, ctx)
|
46
|
-
if value.nil?
|
47
|
-
result = GraphQL::Query::InputValidationResult.new
|
48
|
-
result.add_problem("Expected value to not be null")
|
49
|
-
result
|
50
|
-
else
|
51
|
-
of_type.validate_input(value, ctx)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def_delegators :@of_type, :coerce_input, :coerce_result, :list?
|
56
|
-
|
57
|
-
def kind
|
58
|
-
GraphQL::TypeKinds::NON_NULL
|
59
|
-
end
|
60
|
-
|
61
|
-
def to_s
|
62
|
-
"#{of_type.to_s}!"
|
63
|
-
end
|
64
|
-
alias_method :inspect, :to_s
|
65
|
-
alias :to_type_signature :to_s
|
66
|
-
|
67
|
-
def non_null?
|
68
|
-
true
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/lib/graphql/object_type.rb
DELETED
@@ -1,130 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
module GraphQL
|
3
|
-
# @api deprecated
|
4
|
-
class ObjectType < GraphQL::BaseType
|
5
|
-
extend Define::InstanceDefinable::DeprecatedDefine
|
6
|
-
|
7
|
-
deprecated_accepts_definitions :interfaces, :fields, :mutation, :relay_node_type, field: GraphQL::Define::AssignObjectField
|
8
|
-
deprecated_accepts_definitions implements: ->(type, *interfaces, inherit: false) { type.implements(interfaces, inherit: inherit) }
|
9
|
-
|
10
|
-
attr_accessor :fields, :mutation, :relay_node_type
|
11
|
-
ensure_defined(:fields, :mutation, :interfaces, :relay_node_type)
|
12
|
-
|
13
|
-
# @!attribute fields
|
14
|
-
# @return [Hash<String => GraphQL::Field>] Map String fieldnames to their {GraphQL::Field} implementations
|
15
|
-
|
16
|
-
# @!attribute mutation
|
17
|
-
# @return [GraphQL::Relay::Mutation, nil] The mutation this object type was derived from, if it is an auto-generated payload type.
|
18
|
-
|
19
|
-
def initialize
|
20
|
-
super
|
21
|
-
@fields = {}
|
22
|
-
@clean_inherited_fields = nil
|
23
|
-
@structural_interface_type_memberships = []
|
24
|
-
@inherited_interface_type_memberships = []
|
25
|
-
end
|
26
|
-
|
27
|
-
def initialize_copy(other)
|
28
|
-
super
|
29
|
-
@structural_interface_type_memberships = other.structural_interface_type_memberships.dup
|
30
|
-
@inherited_interface_type_memberships = other.inherited_interface_type_memberships.dup
|
31
|
-
@fields = other.fields.dup
|
32
|
-
end
|
33
|
-
|
34
|
-
# This method declares interfaces for this type AND inherits any field definitions
|
35
|
-
# @param new_interfaces [Array<GraphQL::Interface>] interfaces that this type implements
|
36
|
-
# @deprecated Use `implements` instead of `interfaces`.
|
37
|
-
def interfaces=(new_interfaces)
|
38
|
-
@structural_interface_type_memberships = []
|
39
|
-
@inherited_interface_type_memberships = []
|
40
|
-
@clean_inherited_fields = nil
|
41
|
-
implements(new_interfaces, inherit: true)
|
42
|
-
end
|
43
|
-
|
44
|
-
def interfaces(ctx = GraphQL::Query::NullContext)
|
45
|
-
ensure_defined
|
46
|
-
visible_ifaces = []
|
47
|
-
unfiltered = ctx == GraphQL::Query::NullContext
|
48
|
-
[@structural_interface_type_memberships, @inherited_interface_type_memberships].each do |tms|
|
49
|
-
tms.each do |type_membership|
|
50
|
-
if unfiltered || type_membership.visible?(ctx)
|
51
|
-
# if this is derived from a class-based object, we have to
|
52
|
-
# get the `.graphql_definition` of the attached interface.
|
53
|
-
visible_ifaces << GraphQL::BaseType.resolve_related_type(type_membership.abstract_type)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
visible_ifaces
|
59
|
-
end
|
60
|
-
|
61
|
-
def kind
|
62
|
-
GraphQL::TypeKinds::OBJECT
|
63
|
-
end
|
64
|
-
|
65
|
-
# This fields doesnt have instrumenation applied
|
66
|
-
# @see [Schema#get_field] Get field with instrumentation
|
67
|
-
# @return [GraphQL::Field] The field definition for `field_name` (may be inherited from interfaces)
|
68
|
-
def get_field(field_name)
|
69
|
-
fields[field_name] || interface_fields[field_name]
|
70
|
-
end
|
71
|
-
|
72
|
-
# These fields don't have instrumenation applied
|
73
|
-
# @see [Schema#get_fields] Get fields with instrumentation
|
74
|
-
# @return [Array<GraphQL::Field>] All fields, including ones inherited from interfaces
|
75
|
-
def all_fields
|
76
|
-
interface_fields.merge(self.fields).values
|
77
|
-
end
|
78
|
-
|
79
|
-
# Declare that this object implements this interface.
|
80
|
-
# This declaration will be validated when the schema is defined.
|
81
|
-
# @param interfaces [Array<GraphQL::Interface>] add a new interface that this type implements
|
82
|
-
# @param inherits [Boolean] If true, copy the interfaces' field definitions to this type
|
83
|
-
def implements(interfaces, inherit: false, **options)
|
84
|
-
if !interfaces.is_a?(Array)
|
85
|
-
raise ArgumentError, "`implements(interfaces)` must be an array, not #{interfaces.class} (#{interfaces})"
|
86
|
-
end
|
87
|
-
@clean_inherited_fields = nil
|
88
|
-
|
89
|
-
type_memberships = inherit ? @inherited_interface_type_memberships : @structural_interface_type_memberships
|
90
|
-
interfaces.each do |iface|
|
91
|
-
iface = BaseType.resolve_related_type(iface)
|
92
|
-
if iface.is_a?(GraphQL::InterfaceType)
|
93
|
-
type_memberships << iface.type_membership_class.new(iface, self, **options)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def resolve_type_proc
|
99
|
-
nil
|
100
|
-
end
|
101
|
-
|
102
|
-
attr_writer :structural_interface_type_memberships
|
103
|
-
|
104
|
-
protected
|
105
|
-
|
106
|
-
attr_reader :structural_interface_type_memberships, :inherited_interface_type_memberships
|
107
|
-
|
108
|
-
private
|
109
|
-
|
110
|
-
def normalize_interfaces(ifaces)
|
111
|
-
ifaces.map { |i_type| GraphQL::BaseType.resolve_related_type(i_type) }
|
112
|
-
end
|
113
|
-
|
114
|
-
def interface_fields
|
115
|
-
if @clean_inherited_fields
|
116
|
-
@clean_inherited_fields
|
117
|
-
else
|
118
|
-
ensure_defined
|
119
|
-
@clean_inherited_fields = {}
|
120
|
-
@inherited_interface_type_memberships.each do |type_membership|
|
121
|
-
iface = GraphQL::BaseType.resolve_related_type(type_membership.abstract_type)
|
122
|
-
if iface.is_a?(GraphQL::InterfaceType)
|
123
|
-
@clean_inherited_fields.merge!(iface.fields)
|
124
|
-
end
|
125
|
-
end
|
126
|
-
@clean_inherited_fields
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|