Sha256: 8fdcb9e5c87561c91c76e9cc5ef8ba1f5dcac7c9dbc9c8168a0f77f549a91326
Contents?: true
Size: 1.22 KB
Versions: 39
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module GraphQL module Types module Relay # This can be used for implementing `Query.node(id: ...)`, # or use it for inspiration for your own field definition. # # @example Adding this field directly # add_field(GraphQL::Types::Relay::NodeField) # # @example Implementing a similar field in your own Query root # # field :node, GraphQL::Types::Relay::Node, null: true, # description: "Fetches an object given its ID" do # argument :id, ID, required: true # end # # def node(id:) # context.schema.object_from_id(id, context) # end # NodeField = GraphQL::Schema::Field.new( name: "node", owner: nil, type: GraphQL::Types::Relay::Node, null: true, description: "Fetches an object given its ID.", relay_node_field: true, ) do argument :id, "ID!", required: true, description: "ID of the object." def resolve(obj, args, ctx) ctx.schema.object_from_id(args[:id], ctx) end def resolve_field(obj, args, ctx) resolve(obj, args, ctx) end end end end end
Version data entries
39 entries across 39 versions & 1 rubygems