You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PostGraphile recognizes columns as unique only if they have a unique constraint and not when a unique index is created
While this is not a direct problem with postgraphile, the solution below can help those that use postgraphile in conjunction with prisma. As mentioned here, prisma doesn't set a unique constraint on a column using the @unique directive. Instead, it only creates a unique index. Consequently, postgraphile doesn't recognize those columns as unique, which causes a few issues.
Steps to reproduce
Add the @unique directive in a prisma schema. Also, run the migration against the database.
Expected results
Columns marked with @unique directive to be considered unique by postgraphile.
Actual results
Columns marked with @unique directive are ignored.
Possible Solution
Create this plugin and include it in your graphile config.
benjie
changed the title
Postgraphile recognizes columns as unique only if they have a unique constraint and not when a unique index is created
"Gather" plugin example: treating unique indexes similarly to unique constraints
May 9, 2024
Summary
PostGraphile recognizes columns as unique only if they have a unique constraint and not when a unique index is created
While this is not a direct problem with postgraphile, the solution below can help those that use postgraphile in conjunction with prisma. As mentioned here, prisma doesn't set a unique constraint on a column using the
@unique
directive. Instead, it only creates a unique index. Consequently, postgraphile doesn't recognize those columns as unique, which causes a few issues.Steps to reproduce
Add the
@unique
directive in a prisma schema. Also, run the migration against the database.Expected results
Columns marked with
@unique
directive to be considered unique by postgraphile.Actual results
Columns marked with
@unique
directive are ignored.Possible Solution
Create this plugin and include it in your graphile config.
The text was updated successfully, but these errors were encountered: