本番対応Auth
Hasura GraphQL APIは、アプリの管理者と正規ユーザーの両方に多くのクエリを公開します。この権限は各ロールに対して明確に定義されます。しかし、これらに加えて、実行するクエリのリストを正確に指定できます。
許可リストは、GraphQL Engineがメタデータに保存する安全なクエリ(GraphQLクエリ、ミューテーション、またはサブスクリプション)のリストです。
HASURA_GRAPHQL_ENABLE_ALLOWLIST
という環境変数によって許可リストを有効にできます。
Slackアプリには、多くのクエリとミューテーションがあり、サーバーが実行できるのはこれらのみです。
例えば、slackアプリに必要なクエリの一部としては、以下が上げられます。
- ユーザーが参加しているワークスペースのリストの取得
query {users {workspaces {idname}}}
- ワークスペース内のチャンネルのリストの取得
query getChannelsInWorkspace($workspaceId: uuid_comparison_exp) {channel(where: {workspace_id: $workspaceId}) {idnamecreated_by}}
これは変数を使用するため、同じクエリが変数に対して異なる値を持つことが許可されることに注意してください。
- チャンネルに投稿されたメッセージのリストの取得
query getChannelsInWorkspace($workspaceId: uuid_comparison_exp, $offset: Int!) {channel(where: {workspace_id: $workspaceId}, limit: 20, offset: $offset) {idnamechannel_threads {channel_thread_messages {idmessage}}}}
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

