hasura / hasura/graphql-engine

String cast issue: field name is a graphql type and a reserved words in many languages

Open
#8,617 2 comments 0 reactions 0 assignees View on GitHub
k/enhancement
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

### Version Information

Server Version: 2.8.0
CLI Version (for CLI related issue): 2.8.0

### Environment

OSS

### What is the expected behaviour?

Fields in the graphql schema don't clash with graphql types and common reserved words in many languages.

### Keywords

cast, String, jsonb

### What is the current behaviour?

Schema contains fields named `String`. E.g.:
```
input jsonb_cast_exp {
String: String_comparison_exp
}
```

### How to reproduce the issue?

1. Export schema that uses jsonb, or any of the postgres types in https://github.com/hasura/graphql-engine/pull/8524

### Screenshots or Screencast

Error in autogenerated dart code for flutter app:

![Screen Shot 2022-06-21 at 9 09 44 PM](https://user-images.githubusercontent.com/12447726/175142957-b072ef66-8757-4086-9980-d7382601f4fd.png)

### Please provide any traces or logs that could help here.

Issue exists with JSONB since 2.5.0, but recently it was added to other types in this PR: https://github.com/hasura/graphql-engine/pull/8524

### Any possible solutions?

Use `string` or `_String`.

### Can you identify the location in the source code where the problem exists?

Not sure.

### If the bug is confirmed, would you be willing to submit a PR?

If someone can point me to the code, yes.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing pull request #8524 and the schema export path for JSONB and other PostgreSQL types. Reproduce the exported schema and inspect the generated Dart code; done means generated field names no longer collide with GraphQL types or common language reserved words.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter, postgresql
Domain
api, backend-api-design, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.