测试权限
现在开始通过 GraphQL API 测试todos表的权限。
查询
现在继续,通过添加两个请求头查询数据:
x-hasura-role:userx-hasura-user-id:1
query {todos {idtitleis_publicis_completeduser_id}}
你应该会得到类似这样的响应:

请注意,你收到的响应已针对用户 id 1进行了过滤。如果你将x-hasura-user-id的值改为2,则将仅返回用户 id 2的数据。这确认了我们在先前步骤中配置的权限。
你也可以以类似方式测试users表的权限配置。
Did you find this page helpful?
Start with GraphQL on Hasura for Free
Build apps and APIs 10x faster
Built-in authorization and caching
8x more performant than hand-rolled APIs





