Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error creating schema because autogenerated names begin with "__" #2292

Closed
markyys opened this issue Dec 30, 2024 · 1 comment
Closed

Error creating schema because autogenerated names begin with "__" #2292

markyys opened this issue Dec 30, 2024 · 1 comment

Comments

@markyys
Copy link

markyys commented Dec 30, 2024

Summary

I'm trying to use postgraphile against a schema which has tables whose column names are UUIDs. When it tries to create the graphql schema I get errors like this:

Error: GraphQL schema is invalid:
- Name "__744A113D_1AFB_4EA3_A1D9_C318A1D6821B_ASC" must not begin with "__", which is reserved by GraphQL introspection.
- Name "__744A113D_1AFB_4EA3_A1D9_C318A1D6821B_DESC" must not begin with "__", which is reserved by GraphQL introspection.

This is unexpected, because the column name in question is, from postgres's point of view, "744a113d-1afb-4ea3-a1d9-c318a1d6821b". graphile seems to have automatically converted that into a name beginning with __, but then dies because names are not allowed to begin with __. This seems like a bug.

Steps to reproduce

  1. Create a postgres database, create a schema with any name, create a table with any name which has a column with a uuid name.
  2. Execute postgraphile against that schema.

Expected results

No error.

Actual results

Error: GraphQL schema is invalid:
- Name "__744A113D_1AFB_4EA3_A1D9_C318A1D6821B_ASC" must not begin with "__", which is reserved by GraphQL introspection.
- Name "__744A113D_1AFB_4EA3_A1D9_C318A1D6821B_DESC" must not begin with "__", which is reserved by GraphQL introspection.

Additional context

postgraphile 4.13.0

@benjie
Copy link
Member

benjie commented Jan 3, 2025

In GraphQL, Name must start with _ or A-Za-z; since your names start with a number we're having to automatically prefix them with a single leading _. However, it looks like when this value is fed into the constantCase inflector, it is doubling the leading _.

You can fix this via the inflection system by overriding the orderByColumnEnum inflector: https://github.com/graphile/graphile-engine/blob/e2a8a7cae58ff26947c050505c76c4a30cfe21c6/packages/graphile-build-pg/src/plugins/PgBasicsPlugin.js#L461-L471

Or by overriding the constantCase inflector to replace double leading __ with single.

@benjie benjie closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2025
@github-project-automation github-project-automation bot moved this from 🌳 Triage to ✅ Done in V5.0.0 Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

No branches or pull requests

2 participants