How to define a hash object in GraphQL
If your model has a json field or a serialized hash that you want to expose as a ObjectType
, just specify the hash_key
for each field:
UserPreferenceType = GraphQL::ObjectType.define do
field :name, types.String, hash_key: 'name'
field :value, types.String, hash_key: 'value'
end
Tweet