Class: GraphQLSchema::TypeDefinition
- Inherits:
-
Type
- Object
- Type
- GraphQLSchema::TypeDefinition
show all
- Defined in:
- lib/graphql_schema.rb
Constant Summary
Constants inherited
from Type
GraphQLSchema::Type::BUILTIN
Instance Method Summary
collapse
Methods inherited from Type
#builtin?, #enum?, #initialize, #input_object?, #interface?, #kind, #list?, #object?, #scalar?, #union?
Methods included from NamedHash
#camelize_name, #classify_name, #description, #name, #to_h, #upcase_name
Instance Method Details
#enum_values(include_deprecated: false) ⇒ Object
252
253
254
255
|
# File 'lib/graphql_schema.rb', line 252
def enum_values(include_deprecated: false)
@enum_values ||= @hash.fetch('enumValues').map{ |value_hash| EnumValue.new(value_hash) }.sort_by(&:name)
include_deprecated ? @enum_values : @enum_values.reject(&:deprecated?)
end
|
#fields(include_deprecated: false) ⇒ Object
218
219
220
221
222
|
# File 'lib/graphql_schema.rb', line 218
def fields(include_deprecated: false)
return unless @hash.fetch('fields')
@fields ||= @hash.fetch('fields').map{ |field_hash| Field.new(field_hash) }
include_deprecated ? @fields : @fields.reject(&:deprecated?)
end
|
#fields_by_name ⇒ Object
224
225
226
|
# File 'lib/graphql_schema.rb', line 224
def fields_by_name
@fields_by_name ||= fields(include_deprecated: true).map{ |field| [field.name, field]}.to_h
end
|
#implement?(interface_name) ⇒ Boolean
244
245
246
|
# File 'lib/graphql_schema.rb', line 244
def implement?(interface_name)
interfaces.map(&:name).include?(interface_name)
end
|
228
229
230
|
# File 'lib/graphql_schema.rb', line 228
def input_fields
@input_fields ||= @hash.fetch('inputFields').map{ |field_hash| InputValue.new(field_hash) }
end
|
#interfaces ⇒ Object
240
241
242
|
# File 'lib/graphql_schema.rb', line 240
def interfaces
@interfaces ||= @hash.fetch('interfaces').map{ |type_hash| TypeDeclaration.new(type_hash) }.sort_by(&:name)
end
|
236
237
238
|
# File 'lib/graphql_schema.rb', line 236
def optional_input_fields
@optional_fields ||= input_fields.reject{ |field| field.type.non_null? }
end
|
#possible_types ⇒ Object
248
249
250
|
# File 'lib/graphql_schema.rb', line 248
def possible_types
@possible_types ||= @hash.fetch('possibleTypes').map{ |type_hash| TypeDeclaration.new(type_hash) }.sort_by(&:name)
end
|
232
233
234
|
# File 'lib/graphql_schema.rb', line 232
def required_input_fields
@required_fields ||= input_fields.select{ |field| field.type.non_null? }
end
|