pg_graphql: pg_graphql not returning via API in Supabase
Describe the bug
Not sure if this is a Supabase issue, or an issue with this extension - feel free to move… I can no longer access GraphQL requests in Supbase outside of the .resolve() method in SQL (i.e via an IDE like Postman or Altair).
All I get when I run an introspection query is heartbeat - whereas I can query multiple entities using resolve()… any ideas?
To Reproduce Steps to reproduce the behavior:
- Create a new Supabase project
- Create a table
- Run a GQL query
Via SQL:
select graphql.resolve($$
{
usersCollection(first: 1) {
edges {
node {
id
email
}
}
}
}
$$);
{"data":{"usersCollection":{"edges":[{"node":{"id":"e2fdd949-11d5-4325-9c6f-4b6071f779a5","email":"xxxx@gmail.com"}}]}}}
VIA API:
{
usersCollection(first: 1) {
edges {
node {
id
email
}
}
}
}
{
"data": null,
"errors": [
{
"message": "Unknown field 'usersCollection' on type 'Query'"
}
]
}
Expected behavior The API returns the same data as the SQL.
Versions:
- pg_graphql commit ref: 0.3.1
Additional context Add any other context about the problem here.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 17 (9 by maintainers)
For anyone who stumbles here… it’s very likely that if you’ve just set up your supabase, and you’ve got RLS enabled, there are probably no policies assigned to your db.
Adding a couple of basic policies will get you started.
@joesaunderson To confirm
public
is not being included in thesearch_path
, try running the following through rpc:I’d dropped the public schema and the first two lines (grants) solved the problem.
Just a tip: if you’re encountering this issue and working with column-grained privileges, don’t forget to grant select permission on the column containing the foreign key. 🤓
@joesaunderson
the
anon
andauthenticated
roles do not haveusage
permission on thepublic
schemaOn newly created projects, both roles have usage permission on
public
so take a look through you migration files and double check if any of them altering permsYou can resolve the issue by granting
usage
onpublic
toanon
andauthenticated
. I tested it to confirmplease lmk if that works for you once you’ve had a chance to test it out
thanks Steve. That was great for debugging. It turned out not to be search_path
Not intentionally (I deleted the random table via the UI, then ran a migration against the Database URI)
Similar Discord issues: