Class: GraphQL::Introspection::TypeType

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

Constant Summary

Constants included from Schema::Member::HasFields

Schema::Member::HasFields::CONFLICT_FIELD_NAMES, Schema::Member::HasFields::GRAPHQL_RUBY_KEYWORDS, Schema::Member::HasFields::RUBY_KEYWORDS

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 BaseObject

field

Methods inherited from Schema::Object

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

Methods included from Schema::Member::HasFields

#add_field, #field, #field_class, #get_field, #global_id_field, #own_fields

Methods included from Schema::Member::HasAstNode

#ast_node

Methods included from Schema::Member::HasPath

#path

Methods included from Schema::Member::RelayShortcuts

#connection_type, #connection_type_class, #edge_type, #edge_type_class

Methods included from Schema::Member::Scoped

#scope_items

Methods included from Schema::Member::TypeSystemHelpers

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

Methods included from Schema::Member::BaseDSLMethods::ConfigurationExtension

#inherited

Methods included from Schema::Member::BaseDSLMethods

#accessible?, #authorized?, #default_graphql_name, #description, #graphql_name, #introspection, #introspection?, #mutation, #overridden_graphql_name, #to_graphql, #visible?

Methods included from Relay::TypeExtensions

#connection_type, #define_connection, #define_edge, #edge_type

Methods included from Schema::Member::CachedGraphQLDefinition

#graphql_definition, #initialize_copy, #type_class

Constructor Details

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

Instance Method Details

#enum_values(include_deprecated:) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/graphql/introspection/type_type.rb', line 36

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



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/graphql/introspection/type_type.rb', line 74

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



58
59
60
61
62
63
64
# File 'lib/graphql/introspection/type_type.rb', line 58

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

#interfacesObject



50
51
52
53
54
55
56
# File 'lib/graphql/introspection/type_type.rb', line 50

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

#kindObject



32
33
34
# File 'lib/graphql/introspection/type_type.rb', line 32

def kind
  @object.kind.name
end

#nameObject



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

def name
  object.graphql_name
end

#of_typeObject



86
87
88
# File 'lib/graphql/introspection/type_type.rb', line 86

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

#possible_typesObject



66
67
68
69
70
71
72
# File 'lib/graphql/introspection/type_type.rb', line 66

def possible_types
  if @object.kind.abstract?
    @context.warden.possible_types(@object).sort_by(&:graphql_name)
  else
    nil
  end
end