Method: GraphQL::Schema::FieldExtension.extras

Defined in:
lib/graphql/schema/field_extension.rb

.extras(new_extras = nil) ⇒ Array<Symbol>

If configured, these extras will be added to the field if they aren't already present, but removed by from arguments before the field's resolve is called. (The extras will be present for other extensions, though.)

Parameters:

  • new_extras (Array<Symbol>) (defaults to: nil)

    If provided, assign extras used by this extension

Returns:

  • (Array<Symbol>)

    any extras assigned to this extension



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/graphql/schema/field_extension.rb', line 59

def extras(new_extras = nil)
  if new_extras
    @own_extras = new_extras
  end

  inherited_extras = self.superclass.respond_to?(:extras) ? superclass.extras : nil
  if @own_extras
    if inherited_extras
      inherited_extras + @own_extras
    else
      @own_extras
    end
  elsif inherited_extras
    inherited_extras
  else
    GraphQL::EmptyObjects::EMPTY_ARRAY
  end
end