[GH-ISSUE #28] Support array variables #114

Closed
opened 2026-03-15 11:32:48 +03:00 by kerem · 0 comments
Owner

Originally created by @ARHariri on GitHub (Mar 31, 2020).
Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/28

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

Originally created by @ARHariri on GitHub (Mar 31, 2020). Original GitHub issue: https://github.com/atulmy/gql-query-builder/issues/28 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`](https://nexus.js.org/docs/api-args#docsNav) 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
kerem closed this issue 2026-03-15 11:32:53 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/gql-query-builder#114
No description provided.