Class: Recline::Model

Inherits:
GraphQL::Rails::ActiveReflection::Model
  • Object
show all
Defined in:
lib/recline/model.rb

Class Method Summary collapse

Class Method Details

.field(**kwargs, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/recline/model.rb', line 13

def self.field(**kwargs, &block)
  # We have to define it fresh each time because
  # its name will be modified and its description
  # _may_ be modified.
  field = GraphQL::Field.define do
    type(Recline::Model.interface)
    description('Fetch the content model for the given object.')
    resolve(Recline::ModelReflection)
  end

  if kwargs.any? || block
    field = field.redefine(kwargs, &block)
  end

  field
end

.interfaceObject



3
4
5
6
7
8
9
10
11
# File 'lib/recline/model.rb', line 3

def self.interface
  @interface ||= GraphQL::InterfaceType.define do
    name "ReclineInterface"
    field('_model', Recline::Types::ModelReflectionType, 'Model of attributes for field.') do
      description('Fetch the content model for the given object.')
      resolve(Recline::ModelReflection)
    end
  end
end