I want to model some data structured like map[str, my_interface]
. My first attempt (based on this GraphQL suggestion) was to introduce a new KeyValue
type with the key: String
and value: MyInterface
and then use a list of those, for example:
interface PartitionKey {
id: Int!
}
type DatePartitionKey implements PartitionKey {
key: DateTime!
}
type StringToPartitionKey {
key: String!
value: PartitionKey!
}
type Partition {
keys: [StringToPartitionKey!]!
}
However, when trying to use the query builder, it generates a mutation like:
addPartition(input: {keys: {key: "date"}})
Which notably:
- only allows for entering 1 entry for
keys
(instead of a list) - does not allow entering the
value
(in this case, I want to generate a newDatePartitionKey
) - does run and creates faulty data (the
.keys
field is not aStringToPartitionKey
value w/ not-null fields, but a random object with just akey
field)
–
Is using a [KeyValue!]!
a reasonable approach here and if so, how should this insert mutation be structured? Thanks for any help!