Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a custom context #2856

Open
alberthuang24 opened this issue Sep 25, 2021 · 0 comments
Open

Add a custom context #2856

alberthuang24 opened this issue Sep 25, 2021 · 0 comments

Comments

@alberthuang24
Copy link

For the front-end, the access token may be stored anywhere. Maybe localStorage, cookies, indexedDB.

So we might be able to provide a similar API

mesh.addCustomContextBuilder(() => {
  const accessToken = localStorage.get(‘accessToken');
  return {
    accessToken
  }
});
sources:
  - name: MyGraphQLApi
    handler:
      graphql:
        endpoint: http://my-service-url:3000/graphql
        operationHeaders:
          # Please do not use capital letters while getting the headers
          Authorization: Bearer {context.accessToken}
          # You can also access to the cookies like below;
          # Authorization: Bearer {context.cookies.myApiToken}
@theguild-bot theguild-bot mentioned this issue Aug 11, 2022
@theguild-bot theguild-bot mentioned this issue Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant