Class: GraphQL::Introspection::TypenameField

Inherits:
Object
  • Object
show all
Defined in:
lib/graph_ql/introspection/typename_field.rb

Overview

A wrapper to create ‘__typename`. Uses `.create` because I couldn’t figure out how to pass ‘DEFINITION` via `super` (then I could extend GraphQL::Field)

Constant Summary collapse

DEFINITION =
Proc.new { |f, wrapped_type|
  f.name "__typename"
  f.description "The name of this type"
  f.type -> { !GraphQL::STRING_TYPE }
  f.resolve -> (obj, a, c) { wrapped_type.name }
}

Class Method Summary collapse

Class Method Details

.create(wrapped_type) ⇒ Object



12
13
14
# File 'lib/graph_ql/introspection/typename_field.rb', line 12

def self.create(wrapped_type)
   GraphQL::Field.new { |f| DEFINITION.call(f, wrapped_type) }
end