hasura / hasura/graphql-engine

Invalid schema, when select has no columns

Open
#9,635 0 comments 2 reactions 0 assignees View on GitHub
k/bug t/native-dbs
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version: v2.20.1 - OSS

### What is the current behaviour?

The generated Schema contains an invalid line,
```
input table_stream_cursor_value_input <--- no { }

input table_insert_input {
...
}
```

This upsets apollo, but also the GraphQL-Explorer writes to the console:
```
Uncaught Error: Input Object type table_stream_cursor_value_input must define one or more fields.
at g (validate.mjs:49:11)
at u (validate.mjs:32:3)
at validateWithCustomRules.js:16:20
at gt (getDiagnostics.js:39:47)
at mt (getDiagnostics.js:33:12)
at lint.js:40:59
at h (lint.js:151:25)
at lint.js:199:43
```

### What is the expected behaviour?

The Schema is correct and does not generate errors.

### How to reproduce the issue?

1. New table (actually a VIEW here, but that should not matter(?))
2. Permissions to non-admin role, such that INSERT is allowed, and – because "The single row mutation insert_one shares the returning type with the query field. Hence if no select permissions are defined, the insert_one field will also be omitted from the GraphQL schema." – SELECT permission, but with no column allowed in Column select permissions.
3. Get schema / Use GraphQL-Explorer **as non-admin user**, i.e. send `x-hasura-role`.

The "no-columns"/"empty" select did not cause a bad schema w/ v2.0.3, before the streaming stuff was introduced.

### Any possible solutions/workarounds you're aware of?

Add at least one column to the select, or use `insert` instead of `insert_one` mutation (untested)...

### Keywords

stream cursor input invalid schema

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.