Module: GraphQL::Relay::Node

Defined in:
lib/graphql/relay/node.rb

Overview

Helpers for working with Relay-specific Node objects.

Class Method Summary collapse

Class Method Details

.field(**kwargs, &block) ⇒ GraphQL::Field

Returns a field for finding objects by their global ID.

Returns:

  • (GraphQL::Field)

    a field for finding objects by their global ID.



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/graphql/relay/node.rb', line 7

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::Types::Relay::NodeField.graphql_definition

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

  field
end

.interfaceGraphQL::InterfaceType

Returns The interface which all Relay types must implement.

Returns:



31
32
33
# File 'lib/graphql/relay/node.rb', line 31

def self.interface
  @interface ||= GraphQL::Types::Relay::Node.graphql_definition
end

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



20
21
22
23
24
25
26
27
28
# File 'lib/graphql/relay/node.rb', line 20

def self.plural_field(**kwargs, &block)
  field = GraphQL::Types::Relay::NodesField.graphql_definition

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

  field
end