hasura / hasura/graphql-engine

Support for list variables in query params for RESTified endpoints

Open
#9,409 1 comment 2 reactions 0 assignees View on GitHub
k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Is your proposal related to a problem?

Let's say I created a REST endpoint which accepts`GET` method via Hasura console. In my query, I want to use `_in` operator in my `where` clause. The filter values would be dynamic, so I opted to use query variables. I created REST endpoint based on that query as graphql request.

reference query
```gql
query getArticlesBasedOnRating ($_in: [Int!] = 0) {
articles(where: {rating: {_in: $_in}}) {
rating
title
}
}

```

Currently, if I pass query params as `?_in=1,3,5` in my URL as `my_domain/api/rest/get-data?_in=1,3,5` to HTTP endpoint (REST), then it will throw the following error

```json
{
"code": "bad-request",
"error": "List variables are not currently supported in URL or Query parameters. (Variable _in, with value \"1,3,5\")",
"path": "$"
}
```

### Describe the solution you'd like

Generally, the I've seen that backend is configured to accept comma based string as a value to query param (e.g. `ratings=1,3,5`) which gets interpreted as Array/List form. This may change acc. to spec of hasura's RESTified endpoint. I'll leave it up to the server engineers to decide.

### Describe alternatives you've considered

The workaround for this is to pass query variables in the form of request BODY (raw text/json) . For e.g.
```
{
"_in" : [1,3,5]
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.