hasura / hasura/graphql-engine

Tracking tables with names or in schemas that are invalid GraphQL identifiers silently fails

Open
#8,892 1 comment 0 reactions 0 assignees View on GitHub
k/bug
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### What is the current behaviour?

If you track a table whose default root field name is not a valid GraphQL identifier, tracking the table succeeds, but the table does not show up in the GraphQL schema. No error or warning is provided at an API level.

The console currently displays a warning when tracking a table with invalid characters in its name, and will apply a custom name that fixes it automatically. However, it does not do this if the table resides in a schema that has invalid characters in its name.

This is extremely confusing and unexpected, especially so if you use the metadata API to configure HGE and not the console, as no explanation is given as to why your table is not showing up in GraphQL.

### What is the expected behaviour?

HGE should not allow a table that it cannot put into the GraphQL schema to be tracked. So, if the default root field name is not a valid GraphQL identifier, tracking the table should fail until a custom name is provided to resolve the issue.

### How to reproduce the issue?

Scenario 1: Invalid schema name
1. Create a Postgres schema called "hyphen-schema".
2. Create a table in the schema called "underscore_table"
3. Track this table in HGE via the console or via the metadata API. Observe the successful track operation.
4. Look at the GraphQL schema. Observe that the table does not show up.

Scenario 2: Invalid table name
1. Create a Postgres schema called "underscore_schema".
2. Create a table in the schema called "hyphen-table"
3. Track this table in HGE via the metadata API. Observe the successful track operation.
4. Look at the GraphQL schema. Observe that the table does not show up.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with PostgreSQL schemas and table names containing invalid GraphQL identifier characters, using the metadata API and checking the generated GraphQL schema. Trace the tracking operation and validation path; done means invalid default root field names are rejected with an explanation, while a valid custom name permits tracking.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.