Module: Relay::Node
- Defined in:
- lib/relay/node.rb,
lib/relay/node/plural_identifying_root_field.rb
Defined Under Namespace
Classes: PluralIdentifyingRootFieldConfiguration
Class Method Summary
collapse
Class Method Details
.definitions(fetcher, resolver) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/relay/node.rb', line 10
def self.definitions(fetcher, resolver)
interface = GraphQL::GraphQLInterfaceType.new do
name 'Node'
description 'An object with ID'
field :id, ! GraphQL::GraphQLID do
description 'The id of the object'
end
resolve_type resolver
end
field = GraphQL::GraphQLField.new do
name 'node'
description 'Fetches an object given its ID'
type interface
arg :id, ! GraphQL::GraphQLID do
description 'The ID of an object'
end
resolve lambda { |root, params, info, *args|
fetcher.call(params[:id], info)
}
end
{ interface: interface, field: field }
end
|
.from_global_id(global_id) ⇒ Object
44
45
46
|
# File 'lib/relay/node.rb', line 44
def self.from_global_id(global_id)
return Base64.strict_decode64(global_id).split(':')
end
|
.to_global_id(type, id) ⇒ Object
40
41
42
|
# File 'lib/relay/node.rb', line 40
def self.to_global_id(type, id)
Base64.strict_encode64([type, id].join(':'))
end
|