hasura / hasura/graphql-engine
bug: query remote schema fields cause errors `There can be only one variable named \"$hasura_json_var_1\".`
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: v2.2.0
### Environment
OSS
### What is the expected behaviour?
Query remote schema (Hasura) fields with input variables did not cause errors
### What is the current behaviour?
Query remote schema (Hasura) fields with input variables will cause errors: `There can be only one variable named \"$hasura_json_var_1\".`
### How to reproduce the issue?
1. Prepare environment with Docker compose file bellow:
```yaml
version: '3.5'
services:
postgres1:
image: postgres:13-alpine
environment:
POSTGRES_DB: 'hasura'
POSTGRES_PASSWORD: 'postgres'
postgres2:
image: postgres:13-alpine
environment:
POSTGRES_DB: 'hasura'
POSTGRES_PASSWORD: 'postgres'
hasura1:
restart: on-failure
image: hasura/graphql-engine:v2.2.0
ports:
- 8080:8080
environment:
HASURA_GRAPHQL_DATABASE_URL: 'postgres://postgres:postgres@postgres1/hasura'
HASURA_GRAPHQL_ENABLE_CONSOLE: 'true'
HASURA_GRAPHQL_DEV_MODE: 'true'
hasura2:
restart: on-failure
image: hasura/graphql-engine:v2.2.0
ports:
- 8081:8080
environment:
HASURA_GRAPHQL_DATABASE_URL: 'postgres://postgres:postgres@postgres2/hasura'
HASURA_GRAPHQL_ENABLE_CONSOLE: 'true'
HASURA_GRAPHQL_DEV_MODE: 'true'
```
2. Access Hasura 1 via url: http://localhost:8080 and add Contentful remote schema: `https://graphql.contentful.com/content/v1/spaces/f8bqpb154z8p/environments/master?access_token=9d5de88248563ebc0d2ad688d0473f56fcd31c600e419d6c8962f6aed0150599`
3. Access Hasura 2 via url: http://localhost:8081 and add **Hasura 1 remote schema**: `http://hasura1:8080/v1/graphql`
4. Modify remote schema **Hasura 1** with type and fields prefix with `hasura1_`
5. Execute query bellow in Hasura 2 console:
```graphql
query MyQuery($where: hasura1_LessonFilter, $limit: Int) {
hasura1_lessonCollection(where: $where, limit: $limit) {
total
}
}
```
With variables:
```graphql
{
"where": {
"slug_contains": "a"
},
"limit": 1
}
```
Contributor guide
Research direction
Reproduce the issue using the supplied Docker Compose services, the two Hasura instances, and the remote-schema query in the Hasura console. Trace how the remote schema query handles input variables; done means the query executes without duplicate-variable errors when variables are supplied.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, graphql, postgres
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100