cosmo icon indicating copy to clipboard operation
cosmo copied to clipboard

Header request insert from context

Open rasmusviben opened this issue 1 year ago • 3 comments

Component(s)

router

Is your feature request related to a problem? Please describe.

Currently its not possible to insert headers from context in the router, like we see on Apollo. It requires a custom module, but would be great to have this feature in the pure config file.

Describe the solution you'd like

Etc reading user_id from context in config.yaml

version: '1'
headers:
  all: # Rules for all origin requests
    request:
      - insert:
          name: "User-ID"
          from_context: "user_id"

Describe alternatives you've considered

Create a custom plugin/module that supports to read from context and insert the header.

Additional context

No response

rasmusviben avatar Oct 28 '24 14:10 rasmusviben

WunderGraph commits fully to Open Source and we want to make sure that we can help you as fast as possible. The roadmap is driven by our customers and we have to prioritize issues that are important to them. You can influence the priority by becoming a customer. Please contact us here.

github-actions[bot] avatar Oct 28 '24 14:10 github-actions[bot]

Hi @rasmusviben, thanks for opening an issue. Could you elaborate a bit more on your needs? Do you only want to forward UserID? Thanks.

StarpTech avatar Oct 29 '24 10:10 StarpTech

No, its just an example. I have a bunch of headers - 6-7 values that I would like to read from the context and forward as header, like for apollo: https://www.apollographql.com/docs/graphos/routing/header-propagation - see section "Insert header from context". Might be against rules to link to Apollo from here, but I'll take my chances. :)

Currently I can't see thats possible to do with the cosmo-router without writing a custom module?

rasmusviben avatar Oct 29 '24 10:10 rasmusviben