hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.1k stars 2.77k forks source link

Feature Request: CUID and Prefixed IDs #9479

Open gusfune opened 1 year ago

gusfune commented 1 year ago

Is your proposal related to a problem?

No

Describe the solution you'd like

Allow CUID (Collision-resistant ids) to be generated as IDs alongside UUID and regular Int/BigInt IDs. Also, allow the creation of prefixed IDs per schema. For example, if I have an author schema, I could have a author_clevcj0g4000008k1gkpk9e6h as a Id.

Describe alternatives you've considered

Generating this manually before sending a mutation, but this creates a logic that could be inside Hasura. Currently Prisma allows CUID natively (through their own ORM) and prefixes can be done via Middleware. But in Hasura it's only possible by messing directly with a query.

gusfune commented 1 year ago

I'd like to update this request with a small solution I've build for PGSQL using NadoID as a generator for CUID: https://gist.github.com/gusfune/9edcd4cf8e8213ca5fb7be4c103b4b58