Class: ArSerializer::GraphQL::HashTypeClass
Instance Attribute Summary
Attributes inherited from TypeClass
#except, #only, #type
Instance Method Summary
collapse
Methods inherited from TypeClass
#description, #fields, from, #initialize, #of_type, #validate!
Instance Method Details
#association_type ⇒ Object
248
249
250
251
252
253
254
|
# File 'lib/ar_serializer/graphql/types.rb', line 248
def association_type
type.values.each do |v|
t = TypeClass.from(v, only, except).association_type
return t if t
end
nil
end
|
#collect_types(types) ⇒ Object
241
242
243
244
245
246
|
# File 'lib/ar_serializer/graphql/types.rb', line 241
def collect_types(types)
types[:other] = true
type.values.map do |v|
TypeClass.from(v, only, except).collect_types(types)
end
end
|
#gql_type ⇒ Object
256
257
258
|
# File 'lib/ar_serializer/graphql/types.rb', line 256
def gql_type
'OBJECT'
end
|
#kind ⇒ Object
233
234
235
|
# File 'lib/ar_serializer/graphql/types.rb', line 233
def kind
'SCALAR'
end
|
#name ⇒ Object
237
238
239
|
# File 'lib/ar_serializer/graphql/types.rb', line 237
def name
:other
end
|
#sample ⇒ Object
260
261
262
263
264
|
# File 'lib/ar_serializer/graphql/types.rb', line 260
def sample
type.reject { |k| k.to_s.ends_with? '?' }.transform_values do |v|
TypeClass.from(v).sample
end
end
|
#ts_type ⇒ Object
266
267
268
269
270
271
272
|
# File 'lib/ar_serializer/graphql/types.rb', line 266
def ts_type
fields = type.map do |key, value|
k = key.to_s == '*' ? '[key: string]' : key
"#{k}: #{TypeClass.from(value, only, except).ts_type}"
end
"{ #{fields.join('; ')} }"
end
|