Class: GraphQLSchema::Type

Inherits:
Object
  • Object
show all
Includes:
NamedHash
Defined in:
lib/graphql_schema.rb

Direct Known Subclasses

TypeDeclaration, TypeDefinition

Constant Summary collapse

BUILTIN =
%w(Int Float String Boolean ID).to_set

Instance Method Summary collapse

Methods included from NamedHash

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

Constructor Details

#initialize(type_hash) ⇒ Type

Returns a new instance of Type.



145
146
147
# File 'lib/graphql_schema.rb', line 145

def initialize(type_hash)
  @hash = type_hash
end

Instance Method Details

#builtin?Boolean

Returns:

  • (Boolean)


181
182
183
# File 'lib/graphql_schema.rb', line 181

def builtin?
  name.start_with?("__") || BUILTIN.include?(name)
end

#enum?Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/graphql_schema.rb', line 169

def enum?
  kind == 'ENUM'
end

#input_object?Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/graphql_schema.rb', line 161

def input_object?
  kind == 'INPUT_OBJECT'
end

#interface?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/graphql_schema.rb', line 165

def interface?
  kind == 'INTERFACE'
end

#kindObject



149
150
151
# File 'lib/graphql_schema.rb', line 149

def kind
  @hash.fetch('kind')
end

#list?Boolean

Returns:

  • (Boolean)


177
178
179
# File 'lib/graphql_schema.rb', line 177

def list?
  kind == 'LIST'
end

#object?Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/graphql_schema.rb', line 157

def object?
  kind == 'OBJECT'
end

#scalar?Boolean

Returns:

  • (Boolean)


153
154
155
# File 'lib/graphql_schema.rb', line 153

def scalar?
  kind == 'SCALAR'
end

#union?Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/graphql_schema.rb', line 173

def union?
  kind == 'UNION'
end