hasura / hasura/graphql-engine

Allow overriding the request role via a GraphQL directive

Open
#3,566 6 comments 1 reaction 0 assignees View on GitHub
c/server k/ideas
Dominant language
TypeScript
Stars
32.1k
Forks
3k
PR merge metrics
PR metrics pending

Description

As mentioned [on Discord](https://discordapp.com/channels/407792526867693568/620480540281405440/620483298845655041), it isn’t possible to change the role used by an existing websocket connection, since `X-Hasura-Role` is sent as a header when opening the connection. @0x777 suggests allowing a special `@hasura(role:)` directive on a GraphQL operation definition, like this:

```graphql
subscription s @hasura(role: "new-role") {
vote_count {
article_id
count
}
}
```

This would override the role that would otherwise be used for that particular request.

Contributor guide

Open the contributing guide

Research direction

The issue identifies the websocket connection's X-Hasura-Role header and proposes a @hasura(role:) directive on GraphQL operation definitions. Start by tracing request role selection for websocket operations; done means the directive overrides the connection role for that request. No files or tests are named, so the relevant entry points and coverage must first be located.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api, authorization, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.