hasura / hasura/graphql-engine

Remote Schema Custom Types Not Included in Hasura 2.0 Schema

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

Description

We have a remote schema running `"apollo-server-express": "^2.18.2"`.
We define our types using `"nexus": "^1.0.0"`.

Previously, using Hasura 1.3.3, if our server exposed custom types, for example:
```graphql
type Result {
id: String!
}

enum Stage {
start
finish
}
```

These custom types would be stitched into our Hasura schema and could be accessed by introspection, thereby allowing us to use Hasura as a central source of truth for all GraphQL types.

However, in Hasura 2.0, **if these types are not directly related to a query or mutation, these types are not included in the Hasura schema**.

We noticed that the apollo server root level types `Mutation` and `Query` are also excluded. Instead, they are added into Hasura's `mutation_root` and `query_root`.

For example, if we have a mutation in our remote schema:
```graphql
type Mutation {
start_job(id: String!): Result!
}
```

In Hasura we can introspect:
```graphql
type mutation_root {
start_job(id: String!): Result!
}

type Result {
id: String!
}
```

But `enum Stage` is not available.

We've also noticed that if we enable `HASURA_GRAPHQL_ENABLE_REMOTE_SCHEMA_PERMISSIONS`, Hasura does give us an option to attach permissions to un-exposed remote schema types, but when we try and add a permission, Hasura fails with the error:
```
Saving permission failed
"Query" has to be an object type
```

Our current workaround is putting these custom types in placeholder query so we can access them by introspection.

Would appreciate any help!

Contributor guide

Open the contributing guide

Research direction

No implementation file, test, or entry point is named. Start by reproducing the remote-schema introspection and permissions behavior described for Hasura 2.0, comparing it with 1.3.3; done means unreferenced custom types such as Stage are available as intended and permissions no longer fail on the root type.

Written by the indexing model from the issue text.

Assessment

Tech stack
express, graphql
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.