Module: GraphQL::Schema::Member::Instrumentation Private

Defined in:
lib/graphql/schema/member/instrumentation.rb

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

Defined Under Namespace

Classes: ProxiedResolve

Class Method Summary collapse

Class Method Details

.after_query(_query) ⇒ 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.



36
37
# File 'lib/graphql/schema/member/instrumentation.rb', line 36

def after_query(_query)
end

.before_query(query) ⇒ 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.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/graphql/schema/member/instrumentation.rb', line 20

def before_query(query)
  # Get the root type for this query
  root_node = query.irep_selection
  if root_node.nil?
    # It's an invalid query, nothing to do here
  else
    root_type = query.irep_selection.return_type
    # If it has a wrapper, apply it
    wrapper_class = root_type.[:type_class]
    if wrapper_class
      new_root_value = wrapper_class.authorized_new(query.root_value, query.context)
      query.root_value = new_root_value
    end
  end
end

.instrument(type, field) ⇒ 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.



9
10
11
12
13
14
15
16
17
18
# File 'lib/graphql/schema/member/instrumentation.rb', line 9

def instrument(type, field)
  return_type = field.type.unwrap
  if (return_type.is_a?(GraphQL::ObjectType) && return_type.[:type_class]) ||
      return_type.is_a?(GraphQL::InterfaceType) ||
      (return_type.is_a?(GraphQL::UnionType) && return_type.possible_types.any? { |t| t.[:type_class] })
    field = apply_proxy(field)
  end

  field
end