apollographql / apollographql/federation

Batch Link Ignores Headers from Gateway

Open
#413 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
725
Forks
276
Avg merge
1h 47m
Merged PRs (30d)
1

Description

I am using an API gateway, that forwards a header `x-server-test`, following the documentation specified here: https://www.apollographql.com/docs/apollo-server/federation/implementing/#customizing-outgoing-responses.

I see the response header show up if I perform a query using fetch directly:
```javascript
const jsonBody = { query: 'query Test { viewer { user { id } } }' }

window.fetch('https://my.gateway.dev:3002/graphql', { method: 'POST', body: JSON.stringify(jsonBody), headers: { 'Content-Type': 'application/json' } })
```

I also see the response header if I perform a query using `apollo-http-link`:
```javascript
const httpLink = createHttpLink({ uri: ... })
```

However, if I use a batch link, the headers never propagate to the client:
```javascript
const batchHttpLink = new BatchHttpLink({ uri: ... })
```

Contributor guide

Open the contributing guide

Research direction

Start by comparing the response handling in the direct fetch and apollo-http-link examples with BatchHttpLink. Trace how BatchHttpLink processes gateway responses and verify that the x-server-test header reaches the client, then confirm the behavior with a batched query.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.