Open RuiLoureiro opened 2 years ago
The error goes away when passing a superuser in the connection string, to postgraphile (instead of user
), so I guess this plugin is trying to access something it doesn't have access to.
@RuiLoureiro thanks for raising the issue. There are two things at play here:
@graphile/federation
package which is not this fork. The lack of update to this README was due to the not knowing whether it would be merged in to the main repo, or left as a separate fork. I will get the README updated to reflect it:npm install postgraphile postgraphile-federation-plugin
docker-compose up
postgraphile -c postgres://user:pass@localhost:5432/db --append-plugins postgraphile-federation-plugin
@mgagliardo91 Thank you for your reply. I have updated the package name, but I'm still getting the same error on a non-empty database. With the postgraphile-federation-plugin
plugin, I get the error and graphiql
shows No Schema Available. If I remove the plugin, everything works.
I tested again that if I give postgraphile a super user (in the connection string), the error goes away.
I'm creating the user for postgraphile with
CREATE ROLE postgraphile login;
GRANT usage ON SCHEMA my-schema TO postgraphile;
Does it need any additional permissions?
Ok I found that the error is happening because I have a table without a primary key The following migration causes the error:
CREATE SCHEMA myschema;
CREATE TABLE myschema.users (
user_id TEXT NOT NULL,
user_name TEXT NOT NULL
);
CREATE ROLE client;
CREATE ROLE postgraphile login;
GRANT usage ON SCHEMA myschema TO client;
GRANT usage ON SCHEMA myschema TO postgraphile;
GRANT SELECT ON TABLE myschema.users TO client;
grant client to postgraphile;
If I add a primary key (PRIMARY KEY(user_id)
), everything works.
Is having a primary key on tables a requirement to using this plugin?
In our use case, because we are using timescaledb, some tables do not have primary keys.
I am trying to run postgraphile v4.12.9 with this plugin, using the provided docker-compose.yml, but I'm getting the following error:
To reproduce:
npm install postgraphile @graphile/federation
docker-compose up
postgraphile -c postgres://user:pass@localhost:5432/db --append-plugins @graphile/federation