Class: GraphQL::Introspection::TypeType
- Inherits:
-
Introspection::BaseObject
- Object
- Introspection::BaseObject
- GraphQL::Introspection::TypeType
- Defined in:
- lib/graphql/introspection/type_type.rb
Class Method Summary collapse
- .resolve_enum_values(object, context, include_deprecated:) ⇒ Object
- .resolve_fields(object, context, include_deprecated:) ⇒ Object
- .resolve_input_fields(object, context, include_deprecated:) ⇒ Object
- .resolve_interfaces(object, context) ⇒ Object
- .resolve_is_one_of(object, _ctx) ⇒ Object
- .resolve_kind(object, context) ⇒ Object
- .resolve_of_type(object, _ctx) ⇒ Object
- .resolve_possible_types(object, context) ⇒ Object
- .resolve_specified_by_url(object, _ctx) ⇒ Object
Instance Method Summary collapse
- #enum_values(include_deprecated:) ⇒ Object
- #fields(include_deprecated:) ⇒ Object
- #input_fields(include_deprecated:) ⇒ Object
- #interfaces ⇒ Object
- #is_one_of ⇒ Object
- #kind ⇒ Object
- #of_type ⇒ Object
- #possible_types ⇒ Object
- #specified_by_url ⇒ Object
Class Method Details
.resolve_enum_values(object, context, include_deprecated:) ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/graphql/introspection/type_type.rb', line 63 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
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/graphql/introspection/type_type.rb', line 119 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
93 94 95 96 97 98 99 100 101 |
# File 'lib/graphql/introspection/type_type.rb', line 93 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
81 82 83 84 85 86 87 |
# File 'lib/graphql/introspection/type_type.rb', line 81 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
34 35 36 37 |
# File 'lib/graphql/introspection/type_type.rb', line 34 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
55 56 57 |
# File 'lib/graphql/introspection/type_type.rb', line 55 def self.resolve_kind(object, context) object.kind.name end |
.resolve_of_type(object, _ctx) ⇒ Object
135 136 137 |
# File 'lib/graphql/introspection/type_type.rb', line 135 def self.resolve_of_type(object, _ctx) object.kind.wraps? ? object.of_type : nil end |
.resolve_possible_types(object, context) ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/graphql/introspection/type_type.rb', line 107 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
43 44 45 46 47 48 49 |
# File 'lib/graphql/introspection/type_type.rb', line 43 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
77 78 79 |
# File 'lib/graphql/introspection/type_type.rb', line 77 def enum_values(include_deprecated:) self.class.resolve_enum_values(object, context, include_deprecated: include_deprecated) end |
#fields(include_deprecated:) ⇒ Object
131 132 133 |
# File 'lib/graphql/introspection/type_type.rb', line 131 def fields(include_deprecated:) self.class.resolve_fields(object, context, include_deprecated: include_deprecated) end |
#input_fields(include_deprecated:) ⇒ Object
103 104 105 |
# File 'lib/graphql/introspection/type_type.rb', line 103 def input_fields(include_deprecated:) self.class.resolve_input_fields(object, context, include_deprecated: include_deprecated) end |
#interfaces ⇒ Object
89 90 91 |
# File 'lib/graphql/introspection/type_type.rb', line 89 def interfaces self.class.resolve_interfaces(object, context) end |
#is_one_of ⇒ Object
39 40 41 |
# File 'lib/graphql/introspection/type_type.rb', line 39 def is_one_of self.class.resolve_is_one_of(object, context) end |
#kind ⇒ Object
59 60 61 |
# File 'lib/graphql/introspection/type_type.rb', line 59 def kind self.class.resolve_kind(object, context) end |
#of_type ⇒ Object
139 140 141 |
# File 'lib/graphql/introspection/type_type.rb', line 139 def of_type self.class.resolve_of_type(object, context) end |
#possible_types ⇒ Object
115 116 117 |
# File 'lib/graphql/introspection/type_type.rb', line 115 def possible_types self.class.resolve_possible_types(object, context) end |
#specified_by_url ⇒ Object
51 52 53 |
# File 'lib/graphql/introspection/type_type.rb', line 51 def specified_by_url self.class.resolve_specified_by_url(object, context) end |