Class: GraphQL::Introspection::TypeType

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resolve_enum_values(object, context, include_deprecated:) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/graphql/introspection/type_type.rb', line 65

def self.resolve_enum_values(object, context, include_deprecated:)
  if !object.kind.enum?
    nil
  else
    enum_values = context.types.enum_values(object)

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

    enum_values
  end
end

.resolve_fields(object, context, include_deprecated:) ⇒ Object



121
122
123
124
125
126
127
128
129
130
131
# File 'lib/graphql/introspection/type_type.rb', line 121

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

.resolve_input_fields(object, context, include_deprecated:) ⇒ Object



95
96
97
98
99
100
101
102
103
# File 'lib/graphql/introspection/type_type.rb', line 95

def self.resolve_input_fields(object, context, include_deprecated:)
  if object.kind.input_object?
    args = context.types.arguments(object)
    args = args.reject(&:deprecation_reason) unless include_deprecated
    args
  else
    nil
  end
end

.resolve_interfaces(object, context) ⇒ Object



83
84
85
86
87
88
89
# File 'lib/graphql/introspection/type_type.rb', line 83

def self.resolve_interfaces(object, context)
  if object.kind.object? || object.kind.interface?
    context.types.interfaces(object).sort_by(&:graphql_name)
  else
    nil
  end
end

.resolve_is_one_of(object, _ctx) ⇒ Object



36
37
38
39
# File 'lib/graphql/introspection/type_type.rb', line 36

def self.resolve_is_one_of(object, _ctx)
  object.kind.input_object? &&
    object.directives.any? { |d| d.graphql_name == "oneOf" }
end

.resolve_kind(object, context) ⇒ Object



57
58
59
# File 'lib/graphql/introspection/type_type.rb', line 57

def self.resolve_kind(object, context)
  object.kind.name
end

.resolve_of_type(object, _ctx) ⇒ Object



137
138
139
# File 'lib/graphql/introspection/type_type.rb', line 137

def self.resolve_of_type(object, _ctx)
  object.kind.wraps? ? object.of_type : nil
end

.resolve_possible_types(object, context) ⇒ Object



109
110
111
112
113
114
115
# File 'lib/graphql/introspection/type_type.rb', line 109

def self.resolve_possible_types(object, context)
  if object.kind.abstract?
    context.types.possible_types(object).sort_by(&:graphql_name)
  else
    nil
  end
end

.resolve_specified_by_url(object, _ctx) ⇒ Object



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

def self.resolve_specified_by_url(object, _ctx)
  if object.kind.scalar?
    object.specified_by_url
  else
    nil
  end
end

Instance Method Details

#enum_values(include_deprecated:) ⇒ Object



79
80
81
# File 'lib/graphql/introspection/type_type.rb', line 79

def enum_values(include_deprecated:)
  self.class.resolve_enum_values(object, context, include_deprecated: include_deprecated)
end

#fields(include_deprecated:) ⇒ Object



133
134
135
# File 'lib/graphql/introspection/type_type.rb', line 133

def fields(include_deprecated:)
  self.class.resolve_fields(object, context, include_deprecated: include_deprecated)
end

#input_fields(include_deprecated:) ⇒ Object



105
106
107
# File 'lib/graphql/introspection/type_type.rb', line 105

def input_fields(include_deprecated:)
  self.class.resolve_input_fields(object, context, include_deprecated: include_deprecated)
end

#interfaces ⇒ Object



91
92
93
# File 'lib/graphql/introspection/type_type.rb', line 91

def interfaces
  self.class.resolve_interfaces(object, context)
end

#is_one_of ⇒ Object



41
42
43
# File 'lib/graphql/introspection/type_type.rb', line 41

def is_one_of
  self.class.resolve_is_one_of(object, context)
end

#kind ⇒ Object



61
62
63
# File 'lib/graphql/introspection/type_type.rb', line 61

def kind
  self.class.resolve_kind(object, context)
end

#of_type ⇒ Object



141
142
143
# File 'lib/graphql/introspection/type_type.rb', line 141

def of_type
  self.class.resolve_of_type(object, context)
end

#possible_types ⇒ Object



117
118
119
# File 'lib/graphql/introspection/type_type.rb', line 117

def possible_types
  self.class.resolve_possible_types(object, context)
end

#specified_by_url ⇒ Object



53
54
55
# File 'lib/graphql/introspection/type_type.rb', line 53

def specified_by_url
  self.class.resolve_specified_by_url(object, context)
end