class GraphQLSchema::TypeDefinition

Public Instance Methods

enum_values(include_deprecated: false) click to toggle source
# File lib/graphql_schema.rb, line 280
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) click to toggle source
# File lib/graphql_schema.rb, line 246
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() click to toggle source
# File lib/graphql_schema.rb, line 252
def fields_by_name
  @fields_by_name ||= fields(include_deprecated: true).map{ |field| [field.name, field]}.to_h
end
implement?(interface_name) click to toggle source
# File lib/graphql_schema.rb, line 272
def implement?(interface_name)
  interfaces.map(&:name).include?(interface_name)
end
input_fields() click to toggle source
# File lib/graphql_schema.rb, line 256
def input_fields
  @input_fields ||= @hash.fetch('inputFields').map{ |field_hash| InputValue.new(field_hash) }
end
interfaces() click to toggle source
# File lib/graphql_schema.rb, line 268
def interfaces
  @interfaces ||= @hash.fetch('interfaces').map{ |type_hash| TypeDeclaration.new(type_hash) }.sort_by(&:name)
end
optional_input_fields() click to toggle source
# File lib/graphql_schema.rb, line 264
def optional_input_fields
  @optional_fields ||= input_fields.reject{ |field| field.type.non_null? }
end
possible_types() click to toggle source
# File lib/graphql_schema.rb, line 276
def possible_types
  @possible_types ||= @hash.fetch('possibleTypes').map{ |type_hash| TypeDeclaration.new(type_hash) }.sort_by(&:name)
end
required_input_fields() click to toggle source
# File lib/graphql_schema.rb, line 260
def required_input_fields
  @required_fields ||= input_fields.select{ |field| field.type.non_null? }
end