hasura / hasura/graphql-engine
server: support Kriti templating in remote schema URL field
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Is your proposal related to a problem?
Right now the only option is to pass static URL. But in some cases we want to pass access_token in URL for schema stiching purpose which interacts with third party service.
This feature would unlock providing dynamic value at runtime for env var mentioned in URL.
We can utilize Kriti templating in URL field of remote schema like
```
{{REMOTE_SCHEMA_URL}}?access-token={{if empty($.request.headers?[x-contentful--preview])}}{{CF_DELIVERY_TOKEN}}{{else}}{{CF_PREVIEW_TOKEN}}{{end}}
```
One use case is about [Contentful](https://www.contentful.com/developers/docs/references/graphql/) (which is content publishing related platform)
> Ideally, we want to override the access_token in the schema stitching URL based on a header in the client.
Using this feature, users can tackle the problem of switching out the delivery/preview access token at runtime to support [Contentful](https://www.contentful.com/developers/docs/references/graphql/#/introduction/previewing-content) real-time preview feature.
### Describe the solution you'd like
It can be same format as for data connector , i.e. akin to data connector URL - https://hasura.io/docs/latest/databases/database-config/data-connector-config/
It would mean that we would need to resolve the URL on-the-fly every time request would come in. Right now it's static so based on that it already creates GraphQL cache and presents it on top of GraphQL API.
Contributor guide
Research direction
Start by tracing the remote schema URL handling and the existing data connector URL templating behavior. Done means Kriti expressions in remote schema URLs resolve per request, support the described header-based token selection, and preserve correct schema caching behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100