With GraphQL-ruby I want to define a type for a field that holds data in the following structure:
[
["2016-06-07", 14134.84],
["2016-06-08", 14134.84],
# ...
]
How would I go for this? I tried
module Types
class PerformanceDataType < Types::BaseObject
field :assets, [[Types::AssetType]], null: false
# ....
end
end
module Types
class AssetType < Types::BaseObject
field :date, String, null: false
field :value, Float, null: false
end
end
I am not using that data yet so I can't say if it works, but it feels too unspecific. Generating the schema didn't throw any errors.
We ended up doing it like follows:
# innerArrayType.rb
module Types
class InnerArrayType < Types::BaseObject
field :first_value, GraphQL::Types::ISO8601Date, null: false
field :second_value, Types::DecimalType, null: false
end
end
# someOtherType.rb
module Types
class SomeDataType < Types::BaseObject
field :desiredType, [Types::InnerArrayType], null: false
end
end
I guess the takeaway is that on the lowest level, an array must be defined using Types::BaseObject.