graphjin icon indicating copy to clipboard operation
graphjin copied to clipboard

Add support for only reading tables from specified schemas

Open mohsini172 opened this issue 3 years ago • 4 comments

Currently if we try to graphjin as library, we need to call core.NewGraphJin() with a config value and db object. But there's no way to specify a postgres schema for which we want to generate the Graphql. Is it possible? If no, any ideas about how should we implement it? (I want contribute in it)

mohsini172 avatar Mar 17 '22 13:03 mohsini172

If you're using the serv package then you can set a schema but in core you have to set the schema on the db object before passing it to core.NewGraphJin(). There is no way in go to set the schema on the db object. This is how we do it in the 'serv package https://github.com/dosco/graphjin/blob/dea9e1a1959dcc7d7c47df15cae7c8206a57a292/serv/db.go#L146

dosco avatar Mar 17 '22 21:03 dosco

I actually looked into the code and even using a different schema for the serv package was not preventing it from generating graphql queries, mutations etc for other schemas. So I don't think it will be a small change and I don't think it's worth time and effort for now. For me personally, I'll be participating in a hackathon with different databases, rather than schemas so that will solve my problem for now.

mohsini172 avatar Mar 17 '22 22:03 mohsini172

Did you want to limit it to one schema? The discovery code pulls in everything since I want to allow folks to query across schemas.

dosco avatar Mar 18 '22 20:03 dosco

We are running to a similar issue. We use IntrospectionQuery to query the schema but currently it returns schema for all tables in the database. The problem is that we have one Postgres table in public schema that has 100 partitions in another schema in the same database. Currently the IntrospectionQuery returns schema for all tables in the database resulting in a huge and hard to process response.

We need a way to limit the IntrospectionQuery output just to the a single database schema. In case of normal queries and mutations one can use RoleTable in engine configuration to control which tables will be queryable. This does not seem to affect the IntrospectionQuery though.

petmal avatar May 12 '22 15:05 petmal

We now have a @schema(name: "blah") selector level directive.

dosco avatar Oct 01 '22 17:10 dosco