graphql 2.0.17.2 → 2.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/ast.rb +2 -2
  3. data/lib/graphql/backtrace/tracer.rb +1 -1
  4. data/lib/graphql/execution/interpreter/resolve.rb +19 -0
  5. data/lib/graphql/execution/interpreter/runtime.rb +96 -88
  6. data/lib/graphql/execution/interpreter.rb +8 -13
  7. data/lib/graphql/execution/lazy.rb +2 -4
  8. data/lib/graphql/execution/multiplex.rb +2 -1
  9. data/lib/graphql/graphql_ext.bundle +0 -0
  10. data/lib/graphql/language/lexer.rb +216 -1505
  11. data/lib/graphql/language/lexer.ri +744 -0
  12. data/lib/graphql/language/parser.rb +9 -9
  13. data/lib/graphql/language/parser.y +9 -9
  14. data/lib/graphql/pagination/active_record_relation_connection.rb +0 -8
  15. data/lib/graphql/query/context.rb +45 -11
  16. data/lib/graphql/query.rb +15 -2
  17. data/lib/graphql/schema/field.rb +31 -21
  18. data/lib/graphql/schema/member/has_deprecation_reason.rb +3 -4
  19. data/lib/graphql/schema/member/has_fields.rb +6 -1
  20. data/lib/graphql/schema/object.rb +2 -4
  21. data/lib/graphql/schema/resolver/has_payload_type.rb +9 -9
  22. data/lib/graphql/schema/timeout.rb +23 -27
  23. data/lib/graphql/schema/warden.rb +8 -1
  24. data/lib/graphql/schema.rb +39 -1
  25. data/lib/graphql/static_validation/validator.rb +1 -1
  26. data/lib/graphql/tracing/active_support_notifications_trace.rb +16 -0
  27. data/lib/graphql/tracing/appoptics_trace.rb +231 -0
  28. data/lib/graphql/tracing/appsignal_trace.rb +66 -0
  29. data/lib/graphql/tracing/data_dog_trace.rb +148 -0
  30. data/lib/graphql/tracing/new_relic_trace.rb +75 -0
  31. data/lib/graphql/tracing/notifications_trace.rb +41 -0
  32. data/lib/graphql/tracing/platform_trace.rb +107 -0
  33. data/lib/graphql/tracing/platform_tracing.rb +15 -3
  34. data/lib/graphql/tracing/prometheus_trace.rb +89 -0
  35. data/lib/graphql/tracing/prometheus_tracing.rb +3 -3
  36. data/lib/graphql/tracing/scout_trace.rb +72 -0
  37. data/lib/graphql/tracing/statsd_trace.rb +56 -0
  38. data/lib/graphql/tracing.rb +136 -39
  39. data/lib/graphql/type_kinds.rb +6 -3
  40. data/lib/graphql/version.rb +1 -1
  41. data/lib/graphql.rb +7 -8
  42. metadata +14 -3
  43. data/lib/graphql/language/lexer.rl +0 -280
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.17.2
4
+ version: 2.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-29 00:00:00.000000000 Z
11
+ date: 2023-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -317,6 +317,7 @@ files:
317
317
  - lib/graphql/execution/multiplex.rb
318
318
  - lib/graphql/execution_error.rb
319
319
  - lib/graphql/filter.rb
320
+ - lib/graphql/graphql_ext.bundle
320
321
  - lib/graphql/integer_decoding_error.rb
321
322
  - lib/graphql/integer_encoding_error.rb
322
323
  - lib/graphql/introspection.rb
@@ -341,7 +342,7 @@ files:
341
342
  - lib/graphql/language/document_from_schema_definition.rb
342
343
  - lib/graphql/language/generation.rb
343
344
  - lib/graphql/language/lexer.rb
344
- - lib/graphql/language/lexer.rl
345
+ - lib/graphql/language/lexer.ri
345
346
  - lib/graphql/language/nodes.rb
346
347
  - lib/graphql/language/parser.rb
347
348
  - lib/graphql/language/parser.y
@@ -534,16 +535,26 @@ files:
534
535
  - lib/graphql/subscriptions/instrumentation.rb
535
536
  - lib/graphql/subscriptions/serialize.rb
536
537
  - lib/graphql/tracing.rb
538
+ - lib/graphql/tracing/active_support_notifications_trace.rb
537
539
  - lib/graphql/tracing/active_support_notifications_tracing.rb
540
+ - lib/graphql/tracing/appoptics_trace.rb
538
541
  - lib/graphql/tracing/appoptics_tracing.rb
542
+ - lib/graphql/tracing/appsignal_trace.rb
539
543
  - lib/graphql/tracing/appsignal_tracing.rb
544
+ - lib/graphql/tracing/data_dog_trace.rb
540
545
  - lib/graphql/tracing/data_dog_tracing.rb
546
+ - lib/graphql/tracing/new_relic_trace.rb
541
547
  - lib/graphql/tracing/new_relic_tracing.rb
548
+ - lib/graphql/tracing/notifications_trace.rb
542
549
  - lib/graphql/tracing/notifications_tracing.rb
550
+ - lib/graphql/tracing/platform_trace.rb
543
551
  - lib/graphql/tracing/platform_tracing.rb
552
+ - lib/graphql/tracing/prometheus_trace.rb
544
553
  - lib/graphql/tracing/prometheus_tracing.rb
545
554
  - lib/graphql/tracing/prometheus_tracing/graphql_collector.rb
555
+ - lib/graphql/tracing/scout_trace.rb
546
556
  - lib/graphql/tracing/scout_tracing.rb
557
+ - lib/graphql/tracing/statsd_trace.rb
547
558
  - lib/graphql/tracing/statsd_tracing.rb
548
559
  - lib/graphql/type_kinds.rb
549
560
  - lib/graphql/types.rb
@@ -1,280 +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_DIGIT = [0-9A-Za-z];
43
- FOUR_DIGIT_UNICODE = UNICODE_DIGIT{4};
44
- N_DIGIT_UNICODE = LCURLY UNICODE_DIGIT{4,} RCURLY;
45
- UNICODE_ESCAPE = '\\u' (FOUR_DIGIT_UNICODE | N_DIGIT_UNICODE);
46
- # https://graphql.github.io/graphql-spec/June2018/#sec-String-Value
47
- STRING_ESCAPE = '\\' [\\/bfnrt];
48
- BLOCK_QUOTE = '"""';
49
- ESCAPED_BLOCK_QUOTE = '\\"""';
50
- BLOCK_STRING_CHAR = (ESCAPED_BLOCK_QUOTE | ^QUOTE | QUOTE{1,2} ^QUOTE);
51
- ESCAPED_QUOTE = '\\"';
52
- STRING_CHAR = ((ESCAPED_QUOTE | ^QUOTE) - BACKSLASH) | UNICODE_ESCAPE | STRING_ESCAPE;
53
- VAR_SIGN = '$';
54
- DIR_SIGN = '@';
55
- ELLIPSIS = '...';
56
- EQUALS = '=';
57
- BANG = '!';
58
- PIPE = '|';
59
- AMP = '&';
60
-
61
- QUOTED_STRING = QUOTE STRING_CHAR* QUOTE;
62
- BLOCK_STRING = BLOCK_QUOTE BLOCK_STRING_CHAR* QUOTE{0,2} BLOCK_QUOTE;
63
- # catch-all for anything else. must be at the bottom for precedence.
64
- UNKNOWN_CHAR = /./;
65
-
66
- # Used with ragel -V for graphviz visualization
67
- str := |*
68
- QUOTED_STRING => { emit_string(ts, te, meta, block: false) };
69
- *|;
70
-
71
- main := |*
72
- INT => { emit(:INT, ts, te, meta) };
73
- FLOAT => { emit(:FLOAT, ts, te, meta) };
74
- ON => { emit(:ON, ts, te, meta, "on") };
75
- FRAGMENT => { emit(:FRAGMENT, ts, te, meta, "fragment") };
76
- TRUE => { emit(:TRUE, ts, te, meta, "true") };
77
- FALSE => { emit(:FALSE, ts, te, meta, "false") };
78
- NULL => { emit(:NULL, ts, te, meta, "null") };
79
- QUERY => { emit(:QUERY, ts, te, meta, "query") };
80
- MUTATION => { emit(:MUTATION, ts, te, meta, "mutation") };
81
- SUBSCRIPTION => { emit(:SUBSCRIPTION, ts, te, meta, "subscription") };
82
- SCHEMA => { emit(:SCHEMA, ts, te, meta) };
83
- SCALAR => { emit(:SCALAR, ts, te, meta) };
84
- TYPE => { emit(:TYPE, ts, te, meta) };
85
- EXTEND => { emit(:EXTEND, ts, te, meta) };
86
- IMPLEMENTS => { emit(:IMPLEMENTS, ts, te, meta) };
87
- INTERFACE => { emit(:INTERFACE, ts, te, meta) };
88
- UNION => { emit(:UNION, ts, te, meta) };
89
- ENUM => { emit(:ENUM, ts, te, meta) };
90
- INPUT => { emit(:INPUT, ts, te, meta) };
91
- DIRECTIVE => { emit(:DIRECTIVE, ts, te, meta) };
92
- REPEATABLE => { emit(:REPEATABLE, ts, te, meta, "repeatable") };
93
- RCURLY => { emit(:RCURLY, ts, te, meta, "}") };
94
- LCURLY => { emit(:LCURLY, ts, te, meta, "{") };
95
- RPAREN => { emit(:RPAREN, ts, te, meta, ")") };
96
- LPAREN => { emit(:LPAREN, ts, te, meta, "(")};
97
- RBRACKET => { emit(:RBRACKET, ts, te, meta, "]") };
98
- LBRACKET => { emit(:LBRACKET, ts, te, meta, "[") };
99
- COLON => { emit(:COLON, ts, te, meta, ":") };
100
- QUOTED_STRING => { emit_string(ts, te, meta, block: false) };
101
- BLOCK_STRING => { emit_string(ts, te, meta, block: true) };
102
- VAR_SIGN => { emit(:VAR_SIGN, ts, te, meta, "$") };
103
- DIR_SIGN => { emit(:DIR_SIGN, ts, te, meta, "@") };
104
- ELLIPSIS => { emit(:ELLIPSIS, ts, te, meta, "...") };
105
- EQUALS => { emit(:EQUALS, ts, te, meta, "=") };
106
- BANG => { emit(:BANG, ts, te, meta, "!") };
107
- PIPE => { emit(:PIPE, ts, te, meta, "|") };
108
- AMP => { emit(:AMP, ts, te, meta, "&") };
109
- IDENTIFIER => { emit(:IDENTIFIER, ts, te, meta) };
110
- COMMENT => { record_comment(ts, te, meta) };
111
-
112
- NEWLINE => {
113
- meta[:line] += 1
114
- meta[:col] = 1
115
- };
116
-
117
- BLANK => { meta[:col] += te - ts };
118
-
119
- UNKNOWN_CHAR => { emit(:UNKNOWN_CHAR, ts, te, meta) };
120
-
121
- *|;
122
- }%%
123
-
124
- # frozen_string_literal: true
125
-
126
- module GraphQL
127
- module Language
128
- module Lexer
129
- def self.tokenize(query_string)
130
- run_lexer(query_string)
131
- end
132
-
133
- # Replace any escaped unicode or whitespace with the _actual_ characters
134
- # To avoid allocating more strings, this modifies the string passed into it
135
- def self.replace_escaped_characters_in_place(raw_string)
136
- raw_string.gsub!(ESCAPES, ESCAPES_REPLACE)
137
- raw_string.gsub!(UTF_8) do |_matched_str|
138
- codepoint_1 = ($1 || $2).to_i(16)
139
- codepoint_2 = $3
140
-
141
- if codepoint_2
142
- codepoint_2 = codepoint_2.to_i(16)
143
- if (codepoint_1 >= 0xD800 && codepoint_1 <= 0xDBFF) && # leading surrogate
144
- (codepoint_2 >= 0xDC00 && codepoint_2 <= 0xDFFF) # trailing surrogate
145
- # A surrogate pair
146
- combined = ((codepoint_1 - 0xD800) * 0x400) + (codepoint_2 - 0xDC00) + 0x10000
147
- [combined].pack('U'.freeze)
148
- else
149
- # Two separate code points
150
- [codepoint_1].pack('U'.freeze) + [codepoint_2].pack('U'.freeze)
151
- end
152
- else
153
- [codepoint_1].pack('U'.freeze)
154
- end
155
- end
156
- nil
157
- end
158
-
159
- private
160
-
161
- %% write data;
162
-
163
- def self.run_lexer(query_string)
164
- data = query_string.unpack(PACK_DIRECTIVE)
165
- eof = data.length
166
-
167
- # Since `Lexer` is a module, store all lexer state
168
- # in this local variable:
169
- meta = {
170
- line: 1,
171
- col: 1,
172
- data: data,
173
- tokens: [],
174
- previous_token: nil,
175
- }
176
-
177
- p ||= 0
178
- pe ||= data.length
179
-
180
- %% write init;
181
-
182
- %% write exec;
183
-
184
- meta[:tokens]
185
- end
186
-
187
- def self.record_comment(ts, te, meta)
188
- token = GraphQL::Language::Token.new(
189
- :COMMENT,
190
- meta[:data][ts, te - ts].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING),
191
- meta[:line],
192
- meta[:col],
193
- meta[:previous_token],
194
- )
195
-
196
- meta[:previous_token] = token
197
-
198
- meta[:col] += te - ts
199
- end
200
-
201
- def self.emit(token_name, ts, te, meta, token_value = nil)
202
- token_value ||= meta[:data][ts, te - ts].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING)
203
- meta[:tokens] << token = GraphQL::Language::Token.new(
204
- token_name,
205
- token_value,
206
- meta[:line],
207
- meta[:col],
208
- meta[:previous_token],
209
- )
210
- meta[:previous_token] = token
211
- # Bump the column counter for the next token
212
- meta[:col] += te - ts
213
- end
214
-
215
- ESCAPES = /\\["\\\/bfnrt]/
216
- ESCAPES_REPLACE = {
217
- '\\"' => '"',
218
- "\\\\" => "\\",
219
- "\\/" => '/',
220
- "\\b" => "\b",
221
- "\\f" => "\f",
222
- "\\n" => "\n",
223
- "\\r" => "\r",
224
- "\\t" => "\t",
225
- }
226
-
227
- UTF_8 = /\\u(?:([\dAa-f]{4})|\{([\da-f]{4,})\})(?:\\u([\dAa-f]{4}))?/i
228
-
229
-
230
- VALID_STRING = /\A(?:[^\\]|#{ESCAPES}|#{UTF_8})*\z/o
231
-
232
- PACK_DIRECTIVE = "c*"
233
- UTF_8_ENCODING = "UTF-8"
234
-
235
- def self.emit_string(ts, te, meta, block:)
236
- quotes_length = block ? 3 : 1
237
- value = meta[:data][ts + quotes_length, te - ts - 2 * quotes_length].pack(PACK_DIRECTIVE).force_encoding(UTF_8_ENCODING) || ''
238
- line_incr = 0
239
- if block && !value.empty?
240
- line_incr = value.count("\n")
241
- value = GraphQL::Language::BlockString.trim_whitespace(value)
242
- end
243
-
244
- if !value.valid_encoding? || !value.match?(VALID_STRING)
245
- meta[:tokens] << token = GraphQL::Language::Token.new(
246
- :BAD_UNICODE_ESCAPE,
247
- value,
248
- meta[:line],
249
- meta[:col],
250
- meta[:previous_token],
251
- )
252
- else
253
- replace_escaped_characters_in_place(value)
254
-
255
- if !value.valid_encoding?
256
- meta[:tokens] << token = GraphQL::Language::Token.new(
257
- :BAD_UNICODE_ESCAPE,
258
- value,
259
- meta[:line],
260
- meta[:col],
261
- meta[:previous_token],
262
- )
263
- else
264
- meta[:tokens] << token = GraphQL::Language::Token.new(
265
- :STRING,
266
- value,
267
- meta[:line],
268
- meta[:col],
269
- meta[:previous_token],
270
- )
271
- end
272
- end
273
-
274
- meta[:previous_token] = token
275
- meta[:col] += te - ts
276
- meta[:line] += line_incr
277
- end
278
- end
279
- end
280
- end