Module: ApolloFederation::Object::ClassMethods

Includes:
HasDirectives
Defined in:
lib/apollo-federation/object.rb

Instance Method Summary collapse

Methods included from HasDirectives

#add_directive, #federation_directives, #own_federation_directives

Instance Method Details

#extend_typeObject



15
16
17
# File 'lib/apollo-federation/object.rb', line 15

def extend_type
  add_directive(name: 'extends')
end

#inaccessibleObject



23
24
25
# File 'lib/apollo-federation/object.rb', line 23

def inaccessible
  add_directive(name: 'inaccessible')
end

#interface_objectObject



27
28
29
# File 'lib/apollo-federation/object.rb', line 27

def interface_object
  add_directive(name: 'interfaceObject')
end

#key(fields:, camelize: true, resolvable: true) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/apollo-federation/object.rb', line 35

def key(fields:, camelize: true, resolvable: true)
  arguments = [
    name: 'fields',
    values: ApolloFederation::FieldSetSerializer.serialize(fields, camelize: camelize),
  ]
  arguments.append(name: 'resolvable', values: resolvable) unless resolvable
  add_directive(
    name: 'key',
    arguments: arguments,
  )
end

#shareableObject



19
20
21
# File 'lib/apollo-federation/object.rb', line 19

def shareable
  add_directive(name: 'shareable')
end

#tag(name:) ⇒ Object



31
32
33
# File 'lib/apollo-federation/object.rb', line 31

def tag(name:)
  add_directive(name: 'tag', arguments: [name: 'name', values: name])
end

#underscore_reference_keys(value = nil) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/apollo-federation/object.rb', line 47

def underscore_reference_keys(value = nil)
  if value.nil?
    if @underscore_reference_keys.nil?
      find_inherited_value(:underscore_reference_keys, false)
    else
      @underscore_reference_keys
    end
  else
    @underscore_reference_keys = value
  end
end