Class: GraphQL::Relay::GlobalIdResolve

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/relay/global_id_resolve.rb

Instance Method Summary collapse

Constructor Details

#initialize(type_name:, property:) ⇒ GlobalIdResolve

Returns a new instance of GlobalIdResolve.



4
5
6
7
# File 'lib/graphql/relay/global_id_resolve.rb', line 4

def initialize(type_name:, property:)
  @property = property
  @type_name = type_name
end

Instance Method Details

#call(obj, args, ctx) ⇒ Object



9
10
11
12
# File 'lib/graphql/relay/global_id_resolve.rb', line 9

def call(obj, args, ctx)
  id_value = obj.public_send(@property)
  ctx.query.schema.node_identification.to_global_id(@type_name, id_value)
end