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.
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.