hasura / hasura/graphql-engine

Changing the data type of a remote schema will break the metadata

Open
#7,470 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

Version:
hasura/graphql-engine:v2.0.7.cli-migrations-v3

Steps to reproduce:

1. Add new input to remote schema (created with [DGS Framework](https://github.com/netflix/dgs-framework/))

```
input FooInput {
attachedFiles: [String]
}
```

1. Reload the remote schema from http://localhost:9695/console/remote-schemas/manage/XXX/details
1. Add permissions to `attachedFiles` field to the user role from http://localhost:9695/console/remote-schemas/manage/XXX/permissions
1. No problem so far
1. Change `attachedFiles` field to `[String!]`

```
input FooInput {
attachedFiles: [String!]
}
```

1. Restart DGS Framework (Spring Boot)
1. Reload remote schema from http://localhost:9695/console/remote-schemas/manage/XXX/details

![image](https://user-images.githubusercontent.com/3993599/130938654-de4675e8-02f6-4c28-be63-9ee2fe0fc731.png)

1. Metadata is broken!

```
Inconsistent object: in remote schema permission for role "user": validation for the given role-based schema failed because expected type of "attachedFiles"("Input object argument") to be [String!] but received [String]
```

![image](https://user-images.githubusercontent.com/3993599/130936110-d10adec4-2ce3-4672-bae8-abe06ea3b7d9.png)

![image](https://user-images.githubusercontent.com/3993599/130937373-50882a3b-3b20-4d9f-acde-c18b6f877ca6.png)

metadata/remote_schemas.yaml is still the old definition.

```
input FooInput {
attachedFiles: [String]
}
```

but remote schema permission is accurately updated.

![image](https://user-images.githubusercontent.com/3993599/130937905-ea82f88e-0ffa-47ff-9bdb-ada39cc89e19.png)

I tried manually editing the metadata/remote_schemas.yaml as follows and reload metadata, but did not fix the problem.

```
input FooInput {
attachedFiles: [String!]
}
```

How can I safely change the data type of a remote schema?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the remote-schema reload and permission update flow described in the issue, then inspect metadata/remote_schemas.yaml and the remote schema permission handling behind the Console details and permissions URLs. Done means changing an input field from [String] to [String!] no longer leaves metadata inconsistent, and reloading metadata succeeds without the reported validation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql
Domain
api, authorization
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.