Sha256: cf3d67d7980172eadbada354834a730a639e678b90af47118c5321b907950055

Contents?: true

Size: 575 Bytes

Versions: 9

Compression:

Stored size: 575 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) {
          Node.to_global_id(type_name, obj.public_send(property))
        }
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
graphql-relay-0.3.6 lib/graphql/relay/global_id_field.rb
graphql-relay-0.3.5 lib/graphql/relay/global_id_field.rb
graphql-relay-0.3.4 lib/graphql/relay/global_id_field.rb
graphql-relay-0.3.3 lib/graphql/relay/global_id_field.rb
graphql-relay-0.3.2 lib/graphql/relay/global_id_field.rb
graphql-relay-0.3.1 lib/graphql/relay/global_id_field.rb
graphql-relay-0.3.0 lib/graphql/relay/global_id_field.rb
graphql-relay-0.2.0 lib/graphql/relay/global_id_field.rb
graphql-relay-0.1.0 lib/graphql/relay/global_id_field.rb