Class: GraphQLSchema::TypeDeclaration

Inherits:
Type
  • Object
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, #object?, #scalar?, #union?

Methods included from NamedHash

#camelize_name, #classify_name, #description, #name, #to_h, #upcase_name

Constructor Details

This class inherits a constructor from GraphQLSchema::Type

Instance Method Details

#list?Boolean

Returns:

  • (Boolean)


191
192
193
# File 'lib/graphql_schema.rb', line 191

def list?
  kind == 'LIST'
end

#non_null?Boolean

Returns:

  • (Boolean)


195
196
197
# File 'lib/graphql_schema.rb', line 195

def non_null?
  kind == 'NON_NULL'
end

#of_typeObject



187
188
189
# File 'lib/graphql_schema.rb', line 187

def of_type
  @of_type ||= TypeDeclaration.new(@hash.fetch('ofType'))
end

#subfields?Boolean

Returns:

  • (Boolean)


216
217
218
219
220
221
222
223
# File 'lib/graphql_schema.rb', line 216

def subfields?
  case unwrap.kind
  when 'OBJECT', 'INTERFACE', 'UNION'
    true
  else
    false
  end
end

#unwrapObject



199
200
201
202
203
204
205
206
# File 'lib/graphql_schema.rb', line 199

def unwrap
  case kind
  when 'NON_NULL', 'LIST'
    of_type.unwrap
  else
    self
  end
end

#unwrap_listObject



208
209
210
# File 'lib/graphql_schema.rb', line 208

def unwrap_list
  list? ? of_type.unwrap_list : self
end

#unwrap_non_nullObject



212
213
214
# File 'lib/graphql_schema.rb', line 212

def unwrap_non_null
  non_null? ? of_type.unwrap_non_null : self
end