Class: ArSerializer::GraphQL::HashTypeClass
Instance Attribute Summary
Attributes inherited from TypeClass
#type
Instance Method Summary
collapse
Methods inherited from TypeClass
#description, #fields, from, #initialize, #of_type
Instance Method Details
#association_type ⇒ Object
233
234
235
236
237
238
239
|
# File 'lib/ar_serializer/graphql/types.rb', line 233
def association_type
type.values.each do |v|
t = v.association_type
return t if t
end
nil
end
|
#collect_types(types) ⇒ Object
226
227
228
229
230
231
|
# File 'lib/ar_serializer/graphql/types.rb', line 226
def collect_types(types)
types[:other] = true
type.values.each do |v|
v.collect_types(types)
end
end
|
#gql_type ⇒ Object
241
|
# File 'lib/ar_serializer/graphql/types.rb', line 241
def gql_type = 'OBJECT'
|
#kind ⇒ Object
222
|
# File 'lib/ar_serializer/graphql/types.rb', line 222
def kind = 'SCALAR'
|
#name ⇒ Object
224
|
# File 'lib/ar_serializer/graphql/types.rb', line 224
def name = :other
|
#to_gql_args ⇒ Object
253
254
255
256
257
|
# File 'lib/ar_serializer/graphql/types.rb', line 253
def to_gql_args
type.map do |key, type|
ArgClass.new key, type
end
end
|
#ts_type ⇒ Object
243
244
245
246
247
248
249
250
251
|
# File 'lib/ar_serializer/graphql/types.rb', line 243
def ts_type
return 'Record<string, never>' if type.empty?
fields = type.map do |key, value|
k = key.to_s == '*' ? '[key: string]' : key
"#{k}: #{value.ts_type}"
end
"{ #{fields.join('; ')} }"
end
|