class GraphQL::Relay::GlobalIdField
@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
Public Class Methods
new(type_name, property: :id)
click to toggle source
# File lib/graphql/relay/global_id_field.rb, line 9 def initialize(type_name, property: :id) self.arguments = {} self.type = !GraphQL::ID_TYPE self.resolve = -> (obj, args, ctx) { ctx.query.schema.node_identification.to_global_id(type_name, obj.public_send(property)) } end