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
19
# File 'lib/graphql/relay/node.rb', line 7

def self.field(**kwargs, &block)
  GraphQL::Deprecation.warn "GraphQL::Relay::Node.field will be removed from GraphQL-Ruby 2.0, use GraphQL::Types::Relay::NodeField instead"
  # 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:


33
34
35
36
# File 'lib/graphql/relay/node.rb', line 33

def self.interface
  GraphQL::Deprecation.warn "GraphQL::Relay::Node.interface will be removed from GraphQL-Ruby 2.0, use GraphQL::Types::Relay::Node instead"
  @interface ||= GraphQL::Types::Relay::Node.graphql_definition
end

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


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

def self.plural_field(**kwargs, &block)
  GraphQL::Deprecation.warn "GraphQL::Relay::Nodes.field will be removed from GraphQL-Ruby 2.0, use GraphQL::Types::Relay::NodesField instead"
  field = GraphQL::Types::Relay::NodesField.graphql_definition

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

  field
end