Module: GraphQL::Types::Relay::HasNodeField
- Defined in:
- lib/graphql/types/relay/has_node_field.rb
Overview
Include this module to your root Query type to get a Relay-compliant node(id: ID!): Node field that uses the schema’s object_from_id hook.
Defined Under Namespace
Modules: ExecutionMethods
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.field_block ⇒ Object
36
37
38
39
40
41
|
# File 'lib/graphql/types/relay/has_node_field.rb', line 36
def field_block
Proc.new {
argument :id, "ID!",
description: "ID of the object."
}
end
|
.field_options ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/graphql/types/relay/has_node_field.rb', line 24
def field_options
{
name: "node",
type: GraphQL::Types::Relay::Node,
null: true,
description: "Fetches an object given its ID.",
relay_node_field: true,
resolver_method: :get_relay_node,
resolve_static: :get_relay_node,
}
end
|
Instance Method Details
#get_relay_node(id:) ⇒ Object
19
20
21
|
# File 'lib/graphql/types/relay/has_node_field.rb', line 19
def get_relay_node(id:)
self.class.get_relay_node(context, id: id)
end
|