0

I want to build an admin tool based on a Hasura backend. Different users will have different level of access based on roles.

Will I be able to do introspection per role and therefore know which fields (from queries) and buttons (for mutations) to show?

  • 1
    Welcome to StackOverflow! What exactly do you mean by "introspection per role"? Is that graphql introspection? If that's so then yes: graphql introspection depends per user role. Users of 'admin' and 'default' roles will see different schemas. And if you activate Allowed List - then introspection will be prohibited if introspection query will not be in Allowed List. – Alex Yu Aug 04 '21 at 00:27
  • Perfect. That's the response I was hoping for! – Georg Hartmann Sep 03 '21 at 19:00
  • Good. Check an extended answer - maybe you'll see something useful for you. – Alex Yu Sep 04 '21 at 05:58
  • Thank you very much! – Georg Hartmann Sep 14 '21 at 22:14

1 Answers1

1

After clarification from OP it became possible to answer this question.

Yes. Hasura generates different schema for different roles.

How to check them?

A. Permissions summary

Go in hasura console to https://[hasura address]/console/data/schema/public/permissions

You will see something similar to:

permissions summary

Note here:

  • admin role has access to all registered objects and all fields
  • other roles have access to different sets of objects and different set of fields with different row security checks.

B. Hasura API Explorer

Go to: https://[your hasura]/console/api-explorer.

Set x-hasura-role in Request Headers:

Request Headers

Try to do queries and mutations.

You'll see that sets of objects and fields are different for different roles.

C. Allowed List

If you activated Allowed List (which is recommended for production) (and if graphql inspection query is not in your Allowed List )

then graphql inspection will be disabled for all roles except admin:

introspection query

For those who are interested in enabling introspection query - check https://github.com/hasura/graphql-engine/blob/master/server/src-rsr/introspection.json

Alex Yu
  • 3,412
  • 1
  • 25
  • 38