Method: GraphQL::Subscriptions::BroadcastAnalyzer#on_enter_field

Defined in:
lib/graphql/subscriptions/broadcast_analyzer.rb

#on_enter_field(node, parent, visitor) ⇒ 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.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/graphql/subscriptions/broadcast_analyzer.rb', line 25

def on_enter_field(node, parent, visitor)
  if (@subscription_broadcastable == false) || visitor.skipping?
    return
  end

  current_field = visitor.field_definition
  current_type = visitor.parent_type_definition
  apply_broadcastable(current_type, current_field)
  if current_type.kind.interface?
    pt = @query.possible_types(current_type)
    pt.each do |object_type|
      ot_field = @query.get_field(object_type, current_field.graphql_name)
      # Inherited fields would be exactly the same object;
      # only check fields that are overrides of the inherited one
      if ot_field && ot_field != current_field
        apply_broadcastable(object_type, ot_field)
      end
    end
  end
end