Support array variables
Closed this issue · 0 comments
I want to pass an array of strings as a variable to a query (e.g. a list of tags that should be searched), I have no choice except change my type from String
to [String]
. Also, if none of the array items can be null or undefined, I should change this to [String!]
.
It doesn't seem good practice, so I suggest using something like Nexus list
to specify both array and nullability of array items.
For example a variable input like this:
tags: {
type: 'String',
value: tags,
list: [true],
required: true,
}
should be generated as: $tags: [String!]!
So the type of Variable should be:
interface Variable {
type: String;
value: any;
list?: true | [boolean];
required: boolean;
}
list: true
means the variable should be in array format but its items are nullable (that equals to list: [false]
list: [true]
means the variable should be in array format and its items are not nullable
and list: undefined
means the variable is not in array format