module GraphQL::Types::Relay::HasNodesField
Include this module to your root Query type to get a Relay-style nodes(id: ID!): [Node] field that uses the schema’s object_from_id hook.
Public Class Methods
→ untyped
Source
# File lib/graphql/types/relay/has_nodes_field.rb, line 46 def field_block Proc.new { #: self as GraphQL::Schema::Field argument :ids, "[ID!]!", description: "IDs of the objects." } end
→ Hash[Symbol, untyped]
Source
# File lib/graphql/types/relay/has_nodes_field.rb, line 33 def field_options { name: "nodes", type: [GraphQL::Types::Relay::Node, null: true], null: false, description: "Fetches a list of objects given a list of IDs.", relay_nodes_field: true, resolver_method: :get_relay_nodes, resolve_static: :get_relay_nodes } end
(singleton(GraphQL::Schema::Object) child_class) → void
Source
# File lib/graphql/types/relay/has_nodes_field.rb, line 13 def self.included(child_class) child_class.field(**field_options, &field_block) child_class.extend(ExecutionMethods) end
Public Instance Methods
(ids: Array[String]) → untyped
Source
# File lib/graphql/types/relay/has_nodes_field.rb, line 26 def get_relay_nodes(ids:) query_class = self.class #: as GraphQL::Types::Relay::HasNodesField::ExecutionMethods query_class.get_relay_nodes(context, ids: ids) end