Class: GraphQL::Introspection::TypeType

Inherits:
Schema::Object show all
Defined in:
lib/graphql/introspection/type_type.rb

Constant Summary

Constants included from Schema::Member::GraphQLTypeNames

Schema::Member::GraphQLTypeNames::Boolean, Schema::Member::GraphQLTypeNames::ID, Schema::Member::GraphQLTypeNames::Int

Instance Attribute Summary

Attributes inherited from Schema::Object

#context, #object

Instance Method Summary collapse

Methods inherited from Schema::Object

fields, implements, #initialize, interfaces, kind, own_interfaces, to_graphql

Methods included from Schema::Member::HasFields

add_default_resolve_module, #add_field, extended, #field, #field_class, #global_id_field, #included, #inherited, #own_fields

Methods included from Schema::Member::CachedGraphQLDefinition

#graphql_definition, #initialize_copy

Methods included from Relay::TypeExtensions

#connection_type, #define_connection, #define_edge, #edge_type

Methods included from Schema::Member::BaseDSLMethods

#description, #graphql_name, #introspection, #mutation, #name, #overridden_graphql_name, #to_graphql, #unwrap

Methods included from Schema::Member::TypeSystemHelpers

#list?, #non_null?, #to_list_type, #to_non_null_type

Constructor Details

This class inherits a constructor from GraphQL::Schema::Object

Instance Method Details

#enum_values(include_deprecated:) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/graphql/introspection/type_type.rb', line 33

def enum_values(include_deprecated:)
  if !@object.kind.enum?
    nil
  else
    enum_values = @context.warden.enum_values(@object)

    if !include_deprecated
      enum_values = enum_values.select {|f| !f.deprecation_reason }
    end

    enum_values
  end
end

#fields(include_deprecated:) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/graphql/introspection/type_type.rb', line 71

def fields(include_deprecated:)
  if !@object.kind.fields?
    nil
  else
    fields = @context.warden.fields(@object)
    if !include_deprecated
      fields = fields.select {|f| !f.deprecation_reason }
    end
    fields.sort_by(&:name)
  end
end

#input_fieldsObject



55
56
57
58
59
60
61
# File 'lib/graphql/introspection/type_type.rb', line 55

def input_fields
  if @object.kind.input_object?
    @context.warden.arguments(@object)
  else
    nil
  end
end

#interfacesObject



47
48
49
50
51
52
53
# File 'lib/graphql/introspection/type_type.rb', line 47

def interfaces
  if @object.kind == GraphQL::TypeKinds::OBJECT
    @context.warden.interfaces(@object)
  else
    nil
  end
end

#kindObject



29
30
31
# File 'lib/graphql/introspection/type_type.rb', line 29

def kind
  @object.kind.name
end

#of_typeObject



83
84
85
# File 'lib/graphql/introspection/type_type.rb', line 83

def of_type
  @object.kind.wraps? ? @object.of_type : nil
end

#possible_typesObject



63
64
65
66
67
68
69
# File 'lib/graphql/introspection/type_type.rb', line 63

def possible_types
  if @object.kind.resolves?
    @context.warden.possible_types(@object)
  else
    nil
  end
end