Class: Skylight::Core::Normalizers::GraphQL::ExecuteMultiplex Private

Inherits:
Base
  • Object
show all
Defined in:
lib/skylight/core/normalizers/graphql/base.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary

Constants inherited from Base

Base::ANONYMOUS, Base::CAT

Instance Attribute Summary

Attributes inherited from Normalizer

#config

Instance Method Summary collapse

Methods inherited from Base

inherited, key, #normalize, register_graphql

Methods inherited from Normalizer

#initialize, #normalize, register

Constructor Details

This class inherits a constructor from Skylight::Core::Normalizers::Normalizer

Instance Method Details

#normalize_after(trace, _span, _name, payload) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/skylight/core/normalizers/graphql/base.rb', line 58

def normalize_after(trace, _span, _name, payload)
  # This is in normalize_after because the queries may not have
  # an assigned operation name before they are executed.
  # For example, if you send a single query with a defined operation name, e.g.:
  # ```graphql
  #   query MyNamedQuery { user(id: 1) { name } }
  # ```
  # ... but do _not_ send the operationName request param, the GraphQL docs[1]
  # specify that the executor should use the operation name from the definition.
  #
  # In graphql-ruby's case, the calculation of the operation name is lazy, and
  # has not been done yet at the point where execute_multiplex starts.
  # [1] https://graphql.org/learn/serving-over-http/#post-request
  queries, has_errors = payload[:multiplex].queries.each_with_object([Set.new, Set.new]) do |query, (names, errors)|
    names << (query.operation_name || ANONYMOUS)
    errors << query.static_errors.any?
  end

  trace.endpoint = "graphql:#{queries.sort.join('+')}"
  trace.compound_response_error_status = if has_errors.all?
                                           :all
                                         elsif !has_errors.none?
                                           :partial
                                         end
end