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(type_hash) ⇒ Object



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

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