supabase / pg_graphql

GraphQL support for PostgreSQL
https://supabase.github.io/pg_graphql
Apache License 2.0
2.88k stars 101 forks source link

RLS fkey nullability fix #536

Closed olirice closed 3 months ago

olirice commented 3 months ago

What kind of change does this PR introduce?

Corrects a nullability error in relationships when RLS is enabled

What is the current behavior?

When all the columns making up a foreign key are not null, the referenced object is considered not null

e.g.

create table account(
    id int primary key
);

create table address(
    id int primary key,
    account_id int not null references account(id)
);

Creates a non-null relationship with the account type

type Address {
  ....
  account: Account!
}

However, if RLS is enabled on the account table, you might not get an account for each address despite the columns being non null.

What is the new behavior?

When RLS is enabled, the relationship is nullable

Additional context

resolves #409