Graphql-engine: Permissions: allow select in subquery only

Created on 25 Jul 2018  路  7Comments  路  Source: hasura/graphql-engine

I need the data of a table to be available for anonymous but not as a direct query (I don't want it to be able to pull my whole knowledgebase).

Not allowed:

query getClients {
  client { ... }
}

Allowed:

query getProjects {
   projects {
      client { ... }
   }
}
server enhancement

Most helpful comment

I would also find such a feature quite useful.

All 7 comments

Hi @nukinuki, i understand the use-case.
@0x777 will explore the feasibility of implementing such a permission feature.

Meanwhile just curious; would you be able to solve your requirement by creating a Postgres VIEW and setting up anonymous permission for that VIEW? Or do you prefer it to be able to set this up via permissions directly?

Creating a view can solve this particular example with object relationship. Any ideas for array relationship?

query getProjects {
   projects {
      contacts {
         contact { ... }
      }
   }
}

The example scheme is:

table project: id, name
table contact: id, name, phone
table project_x_contact: id, project_id, contact_id

@nukinuki Are there any permissions on the projects table? If there aren't then it doesn't matter whether clients can be queried directly or not, you can indirectly just fetch all the clients by fetching all the projects.

Hey @nukinuki Any update on this? Has your use-case been sorted out? If yes, can you close this issue with some additional information?

I would also find such a feature quite useful.

An RFC for hiding top-level query fields (so they can only be accessed through relationships) is published here: https://github.com/0x777/graphql-engine/blob/select-permission-improvements/rfcs/disable-query-and-subscription-root-fields.md

Please feel free to give your comments here: https://github.com/hasura/graphql-engine/pull/4110/files

Closing this in favour of #696

Was this page helpful?
0 / 5 - 0 ratings

Related issues

marionschleifer picture marionschleifer  路  3Comments

rikinsk-zz picture rikinsk-zz  路  3Comments

egislook picture egislook  路  3Comments

shahidhk picture shahidhk  路  3Comments

bogdansoare picture bogdansoare  路  3Comments