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.



42
43
# File 'lib/graphql/schema/member/instrumentation.rb', line 42

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
35
36
37
38
39
40
# 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)
      new_root_value = query.schema.sync_lazy(new_root_value)
      if new_root_value.nil?
        # This is definitely a hack,
        # but we need some way to tell execute.rb not to run.
        query.context[:__root_unauthorized] = true
      end
      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