graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

Cannot include \"XXX.YYY\" in the GraphQL schema because it is not a valid GraphQL identifier

Open iosifnicolae2 opened this issue 3 years ago • 4 comments
trafficstars

Version Information

Server Version: v2.7.0

Environment

OSS

What is the expected behaviour?

The GraphQL identifier should replace the . character from PostgreSQL field name with _

Keywords

it is not a valid GraphQL identifier

What is the current behaviour?

We're receiving the below error:

[
    {
        "definition": {
            "schema": "xxxx",
            "name": "yyyyy"
        },
        "reason": "Inconsistent object: cannot include \"XXX.YYY\" in the GraphQL schema because  it is not a valid GraphQL identifier",
        "name": "table xxxx.yyyyy in source default",
        "type": "table"
    }
]

How to reproduce the issue?

  1. Create a PostgreSQL column named XXX.YYY
  2. Try to track the table which contains the created column
  3. You will receive the above error

Any possible solutions?

Replace . character with _ when generating GraphQL identifier.

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

https://github.com/hasura/graphql-engine/blob/6e8da71ece69e363e9fa5bace3cef8a33e51cc5a/server/src-lib/Hasura/Backends/Postgres/SQL/Types.hs#L265

iosifnicolae2 avatar Jun 16 '22 14:06 iosifnicolae2

Any idea how can I implement this fix by myself?

iosifnicolae2 avatar Jun 16 '22 14:06 iosifnicolae2

I have the same problem but with a - instead of a . (hasura 2.13.0)

I am unable to rename the offending constraint (it's a unique index) because it's not my database

jflambert avatar Oct 19 '22 16:10 jflambert

@coco98 @rikinsk can we take a look at this issue?

Related/duplicate issue: #8687

jflambert avatar Feb 23 '23 15:02 jflambert

I've ran into this issue too. As far as a potential solution, to

Replace . character with _ when generating GraphQL identifier.

one can do that when calling the API by specifying this choice in args.configuration.column_config field of the request, e.g.

{
  "type": "pg_track_table",
  "args": {
    "source": "dev",
    "table": "mytable_v1",
    "configuration": {
      "column_config": {
        "field.blah": {
          "custom_name": "field_blah"
        }
      }
    }
  }
}

This is what Hasura Console UI does when you track via UI (Screenshot 2024-08-21 at 11 36 27). Hardcoding this choice of replacing . with _ into Hasura itself might be not flexible enough for everybody.

dzhus avatar Aug 21 '24 10:08 dzhus