Module: GraphQL::Relay::Node
- Defined in:
- lib/graphql/relay/node.rb
Overview
Helpers for working with Relay-specific Node objects.
Defined Under Namespace
Class Method Summary collapse
-
.field(**kwargs, &block) ⇒ GraphQL::Field
A field for finding objects by their global ID.
-
.interface ⇒ GraphQL::InterfaceType
The interface which all Relay types must implement.
- .plural_field(**kwargs, &block) ⇒ Object
Class Method Details
.field(**kwargs, &block) ⇒ GraphQL::Field
Returns a field for finding objects by their global ID.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# 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::Field.define do type(GraphQL::Relay::Node.interface) description("Fetches an object given its ID.") argument(:id, types.ID.to_non_null_type, "ID of the object.") resolve(GraphQL::Relay::Node::FindNode) relay_node_field(true) end if kwargs.any? || block field = field.redefine(kwargs, &block) end field end |
.interface ⇒ GraphQL::InterfaceType
Returns The interface which all Relay types must implement.
43 44 45 |
# File 'lib/graphql/relay/node.rb', line 43 def self.interface @interface ||= GraphQL::Types::Relay::Node.graphql_definition end |
.plural_field(**kwargs, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/graphql/relay/node.rb', line 26 def self.plural_field(**kwargs, &block) field = GraphQL::Field.define do type(!types[GraphQL::Relay::Node.interface]) description("Fetches a list of objects given a list of IDs.") argument(:ids, types.ID.to_non_null_type.to_list_type.to_non_null_type, "IDs of the objects.") resolve(GraphQL::Relay::Node::FindNodes) relay_nodes_field(true) end if kwargs.any? || block field = field.redefine(kwargs, &block) end field end |