graphql 2.0.11 → 2.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/generators/graphql/templates/schema.erb +3 -0
  3. data/lib/graphql/dataloader/source.rb +9 -0
  4. data/lib/graphql/execution/interpreter/runtime.rb +10 -8
  5. data/lib/graphql/execution/interpreter.rb +185 -59
  6. data/lib/graphql/execution/lookahead.rb +26 -26
  7. data/lib/graphql/execution/multiplex.rb +1 -116
  8. data/lib/graphql/execution.rb +0 -1
  9. data/lib/graphql/introspection/type_type.rb +7 -0
  10. data/lib/graphql/introspection.rb +2 -1
  11. data/lib/graphql/language/printer.rb +8 -5
  12. data/lib/graphql/query/validation_pipeline.rb +4 -0
  13. data/lib/graphql/query/variable_validation_error.rb +2 -2
  14. data/lib/graphql/query/variables.rb +13 -3
  15. data/lib/graphql/query.rb +11 -2
  16. data/lib/graphql/rake_task/validate.rb +1 -1
  17. data/lib/graphql/schema/argument.rb +25 -13
  18. data/lib/graphql/schema/build_from_definition.rb +1 -2
  19. data/lib/graphql/schema/directive/one_of.rb +12 -0
  20. data/lib/graphql/schema/enum.rb +1 -1
  21. data/lib/graphql/schema/field.rb +12 -11
  22. data/lib/graphql/schema/input_object.rb +36 -1
  23. data/lib/graphql/schema/late_bound_type.rb +4 -0
  24. data/lib/graphql/schema/list.rb +19 -5
  25. data/lib/graphql/schema/member/has_arguments.rb +8 -2
  26. data/lib/graphql/schema/member/validates_input.rb +2 -2
  27. data/lib/graphql/schema/non_null.rb +2 -2
  28. data/lib/graphql/schema/scalar.rb +1 -1
  29. data/lib/graphql/schema.rb +13 -3
  30. data/lib/graphql/static_validation/all_rules.rb +1 -0
  31. data/lib/graphql/static_validation/error.rb +2 -2
  32. data/lib/graphql/static_validation/literal_validator.rb +4 -0
  33. data/lib/graphql/static_validation/rules/directives_are_defined.rb +11 -5
  34. data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb +66 -0
  35. data/lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb +29 -0
  36. data/lib/graphql/static_validation/rules/unique_directives_per_location.rb +12 -6
  37. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +1 -1
  38. data/lib/graphql/subscriptions.rb +2 -5
  39. data/lib/graphql/tracing/data_dog_tracing.rb +2 -0
  40. data/lib/graphql/version.rb +1 -1
  41. metadata +6 -4
  42. data/lib/graphql/execution/instrumentation.rb +0 -92
@@ -62,11 +62,8 @@ module GraphQL
62
62
  # @return [void]
63
63
  def trigger(event_name, args, object, scope: nil, context: {})
64
64
  # Make something as context-like as possible, even though there isn't a current query:
65
- context = @schema.context_class.new(
66
- query: GraphQL::Query.new(@schema, "", validate: false),
67
- object: nil,
68
- values: context
69
- )
65
+ dummy_query = GraphQL::Query.new(@schema, "", validate: false, context: context)
66
+ context = dummy_query.context
70
67
  event_name = event_name.to_s
71
68
 
72
69
  # Try with the verbatim input first:
@@ -75,10 +75,12 @@ module GraphQL
75
75
  end
76
76
 
77
77
  def analytics_enabled?
78
+ # [Deprecated] options[:analytics_enabled] will be removed in the future
78
79
  analytics_available? && Datadog::Contrib::Analytics.enabled?(options.fetch(:analytics_enabled, false))
79
80
  end
80
81
 
81
82
  def analytics_sample_rate
83
+ # [Deprecated] options[:analytics_sample_rate] will be removed in the future
82
84
  options.fetch(:analytics_sample_rate, 1.0)
83
85
  end
84
86
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "2.0.11"
3
+ VERSION = "2.0.14"
4
4
  end
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.11
4
+ version: 2.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-06-20 00:00:00.000000000 Z
11
+ date: 2022-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -303,7 +303,6 @@ files:
303
303
  - lib/graphql/execution.rb
304
304
  - lib/graphql/execution/directive_checks.rb
305
305
  - lib/graphql/execution/errors.rb
306
- - lib/graphql/execution/instrumentation.rb
307
306
  - lib/graphql/execution/interpreter.rb
308
307
  - lib/graphql/execution/interpreter/argument_value.rb
309
308
  - lib/graphql/execution/interpreter/arguments.rb
@@ -394,6 +393,7 @@ files:
394
393
  - lib/graphql/schema/directive/feature.rb
395
394
  - lib/graphql/schema/directive/flagged.rb
396
395
  - lib/graphql/schema/directive/include.rb
396
+ - lib/graphql/schema/directive/one_of.rb
397
397
  - lib/graphql/schema/directive/skip.rb
398
398
  - lib/graphql/schema/directive/transform.rb
399
399
  - lib/graphql/schema/enum.rb
@@ -497,6 +497,8 @@ files:
497
497
  - lib/graphql/static_validation/rules/mutation_root_exists_error.rb
498
498
  - lib/graphql/static_validation/rules/no_definitions_are_present.rb
499
499
  - lib/graphql/static_validation/rules/no_definitions_are_present_error.rb
500
+ - lib/graphql/static_validation/rules/one_of_input_objects_are_valid.rb
501
+ - lib/graphql/static_validation/rules/one_of_input_objects_are_valid_error.rb
500
502
  - lib/graphql/static_validation/rules/operation_names_are_valid.rb
501
503
  - lib/graphql/static_validation/rules/operation_names_are_valid_error.rb
502
504
  - lib/graphql/static_validation/rules/query_root_exists.rb
@@ -595,7 +597,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
595
597
  - !ruby/object:Gem::Version
596
598
  version: '0'
597
599
  requirements: []
598
- rubygems_version: 3.2.22
600
+ rubygems_version: 3.2.33
599
601
  signing_key:
600
602
  specification_version: 4
601
603
  summary: A GraphQL language and runtime for Ruby
@@ -1,92 +0,0 @@
1
- # frozen_string_literal: true
2
- module GraphQL
3
- module Execution
4
- module Instrumentation
5
- # This function implements the instrumentation policy:
6
- #
7
- # - Instrumenters are a stack; the first `before_query` will have the last `after_query`
8
- # - If a `before_` hook returned without an error, its corresponding `after_` hook will run.
9
- # - If the `before_` hook did _not_ run, the `after_` hook will not be called.
10
- #
11
- # When errors are raised from `after_` hooks:
12
- # - Subsequent `after_` hooks _are_ called
13
- # - The first raised error is captured; later errors are ignored
14
- # - If an error was capture, it's re-raised after all hooks are finished
15
- #
16
- # Partial runs of instrumentation are possible:
17
- # - If a `before_multiplex` hook raises an error, no `before_query` hooks will run
18
- # - If a `before_query` hook raises an error, subsequent `before_query` hooks will not run (on any query)
19
- def self.apply_instrumenters(multiplex)
20
- schema = multiplex.schema
21
- queries = multiplex.queries
22
- query_instrumenters = schema.instrumenters[:query]
23
- multiplex_instrumenters = schema.instrumenters[:multiplex]
24
-
25
- # First, run multiplex instrumentation, then query instrumentation for each query
26
- call_hooks(multiplex_instrumenters, multiplex, :before_multiplex, :after_multiplex) do
27
- each_query_call_hooks(query_instrumenters, queries) do
28
- # Let them be executed
29
- yield
30
- end
31
- end
32
- end
33
-
34
- class << self
35
- private
36
- # Call the before_ hooks of each query,
37
- # Then yield if no errors.
38
- # `call_hooks` takes care of appropriate cleanup.
39
- def each_query_call_hooks(instrumenters, queries, i = 0)
40
- if i >= queries.length
41
- yield
42
- else
43
- query = queries[i]
44
- call_hooks(instrumenters, query, :before_query, :after_query) {
45
- each_query_call_hooks(instrumenters, queries, i + 1) {
46
- yield
47
- }
48
- }
49
- end
50
- end
51
-
52
- # Call each before hook, and if they all succeed, yield.
53
- # If they don't all succeed, call after_ for each one that succeeded.
54
- def call_hooks(instrumenters, object, before_hook_name, after_hook_name)
55
- begin
56
- successful = []
57
- instrumenters.each do |instrumenter|
58
- instrumenter.public_send(before_hook_name, object)
59
- successful << instrumenter
60
- end
61
-
62
- # if any before hooks raise an exception, quit calling before hooks,
63
- # but call the after hooks on anything that succeeded but also
64
- # raise the exception that came from the before hook.
65
- rescue GraphQL::ExecutionError => err
66
- object.context.errors << err
67
- rescue => e
68
- raise call_after_hooks(successful, object, after_hook_name, e)
69
- end
70
-
71
- begin
72
- yield # Call the user code
73
- ensure
74
- ex = call_after_hooks(successful, object, after_hook_name, nil)
75
- raise ex if ex
76
- end
77
- end
78
-
79
- def call_after_hooks(instrumenters, object, after_hook_name, ex)
80
- instrumenters.reverse_each do |instrumenter|
81
- begin
82
- instrumenter.public_send(after_hook_name, object)
83
- rescue => e
84
- ex = e
85
- end
86
- end
87
- ex
88
- end
89
- end
90
- end
91
- end
92
- end