Class: GraphQL::Introspection::TypeByNameField

Inherits:
Object
  • Object
show all
Defined in:
lib/graphql/introspection/type_by_name_field.rb

Overview

A wrapper to create __type(name: ) dynamically.

Class Method Summary collapse

Class Method Details

.create(schema) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/graphql/introspection/type_by_name_field.rb', line 5

def self.create(schema)
  GraphQL::Field.define do
    name("__type")
    description("A type in the GraphQL system")
    type(GraphQL::Introspection::TypeType)
    argument :name, !types.String
    resolve ->(o, args, ctx) {
      ctx.warden.get_type(args["name"])
    }
  end
end