Sha256: 87f35881f691a3311b9b846fc9e3fddacb9890ef1fc53dd3ff0bb0663912d35b
Contents?: true
Size: 611 Bytes
Versions: 24
Compression:
Stored size: 611 Bytes
Contents
module GraphQL module Relay # @example Create a field that returns the global ID for an object # RestaurantType = GraphQL::ObjectType.define do # name "Restaurant" # field :id, field: GraphQL::Relay::GlobalIdField.new("Restaurant") # end class GlobalIdField < GraphQL::Field def initialize(type_name, property: :id) self.arguments = {} self.type = !GraphQL::ID_TYPE self.resolve = -> (obj, args, ctx) { GraphQL::Relay::GlobalNodeIdentification.to_global_id(type_name, obj.public_send(property)) } end end end end
Version data entries
24 entries across 24 versions & 1 rubygems