ardatan / ardatan/graphql-mesh

Not all `operationHeaders` are forwarded

Open
#6,471 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
3.5k
Forks
363
Avg merge
6h 10m
Merged PRs (30d)
19

Description

### Issue workflow progress

_Progress of the issue based on the
[Contributor Workflow](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md#a-typical-contributor-workflow)_

- [ ] 1. The issue provides a reproduction available on
[Github](https://github.com/Urigo/graphql-mesh/tree/master/examples/hello-world),
[Stackblitz](https://stackblitz.com/github/Urigo/graphql-mesh/tree/master/examples/hello-world)
or
[CodeSandbox](https://codesandbox.io/s/github/Urigo/graphql-mesh/tree/master/examples/hello-world)

> Make sure to fork this template and run `yarn generate` in the terminal.
>
> Please make sure Mesh package versions under `package.json` matches yours.

- [ ] 2. A failing test has been provided
- [ ] 3. A local solution has been provided
- [ ] 4. A pull request is pending review

---

**Describe the bug**

I recently needed to forward a new custom header by listing it under the `operationHeaders` section in configuration file.

**To Reproduce** Steps to reproduce the behavior:

It's basically nothing special, I just added a new header in configuration file. Here is the meshrc.yaml
```
sources:
- name: CmsApi
handler:
graphql:
endpoint: ${SOME_BASE_URL}/graphql
operationHeaders:
"x-app-name": "{context.headers['x-app-name']}"
"x-app-platform": "{context.headers['x-app-platform']}"

- name: UserApi
handler:
graphql:
endpoint: ${ANOTHER_GQL_API}/graphql
operationHeaders:
Authorization: "{context.headers.authorization}"
"auth-provider": "{context.headers['auth-provider']}"
"x-app-name": "{context.headers['x-app-name']}"
"x-app-platform": "{context.headers['x-app-platform']}"

- name: XdrApi
handler:
jsonSchema:
endpoint: ${XDR_API_BASE_URL}
operations:
- type: Query
field: xdrData
path: /xdr/playhead/account/{args.someArg}/{args.someArg2}
method: GET
responseSchema: ./xdr/json-schemas/playheadData.json
# responseTypeName: xdrData

codegen:
#Default values can be found here https://the-guild.dev/graphql/mesh/docs/guides/graphql-code-generator
skipTypename: true
flattenGeneratedTypes: false
onlyOperationTypes: false
preResolveTypes: false
namingConvention: keep
documentMode: graphQLTag
gqlImport: "@graphql-mesh/utils#gql"
enumsAsTypes: true
ignoreEnumValuesFromSchema: true
useIndexSignature: true
contextType: MeshContext
```
And below is what I got on server side
![image](https://github.com/ardatan/graphql-mesh/assets/6492622/1c460c13-f0df-40de-816e-4e37ebb2d65c)

**Expected behavior**

Obtaining the defined new `x-app-platform` value.

**Environment:**

- OS: Cloudflare Worker
- `@graphql-mesh/...`: `"@graphql-mesh/graphql": "^0.95.2"`
- NodeJS:

**Additional context**

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the configuration shown in meshrc.yaml, using the GraphQL Mesh GraphQL handler and the Cloudflare Worker environment. Trace how operationHeaders are forwarded to the upstream APIs, checking why x-app-platform is omitted while the other configured headers arrive. Done means the configured x-app-platform value reaches the upstream server.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api
Issue type
Bug
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.