Problems with ETags - Apollo router strips Etag

Here is a query directly to my microservice:
`xx@xx:~$ curl -i -X POST -H “Content-Type: application/json” -H “X-User-Id: 4” -d ‘{ “query”: “query { hasUserPhoto }” }’ http://localhost:5017/graphql
HTTP/1.1 200 OK
date: Sun, 16 Feb 2025 16:14:03 GMT
server: uvicorn
content-length: 32
content-type: application/json
vary: ETag
etag: f827cf462f62848df37c5e1e94a4da74

This is the the same query, but now to the Apollo Router: * Host localhost:4999 was resolved.

  • IPv6: ::1
  • IPv4: 127.0.0.1
  • Trying [::1]:4999…
  • connect to ::1 port 4999 from ::1 port 47860 failed: Connection refused
  • Trying 127.0.0.1:4999…
  • Connected to localhost (127.0.0.1) port 4999

POST /graphql HTTP/1.1
Host: localhost:4999
User-Agent: curl/8.5.0
Accept: /
Content-Type: application/json
X-User-Id: 1
Content-Length: 37

< HTTP/1.1 200 OK
< content-type: application/json
< vary: origin
< content-length: 31
< date: Sun, 16 Feb 2025 16:14:54 GMT
<

  • Connection #0 to host localhost left intact`

My router.yaml as i run as conf file:
`supergraph:
introspection: true
listen: 0.0.0.0:4999
path: /graphql

sandbox:
enabled: true

homepage:
enabled: false

headers:
all:
request:
- propagate:
named: “X-User-Id”
`
What is the problem here? Do i need to propagate from the microservice?

Hey @Jensileus, thanks for posting.

The Router out of the box does not propagate response headers from downstream or subgraph services. We leave this up to the users to configure because we don’t know what to do if we were to have a conflicting header value. Keep in mind that your one query today might become a call to multiple services in the future with Federation and cause this conflict.

You can however set the Router response headers to the same value, you will just have to do so with customizations like Rhai scripts or Coprocessors.

See more details here: Header Propagation - Apollo GraphQL Docs

But with the plugin – and here it may be that I am wrong – will we send a entity for the graphql in general? Because since I use federatet i – of course- have multiple services and not all need a ETag. So i want to send the response header from the services that actually uses it. Will the plugin be able to send different ETags or will it send one general for all the services? From the apollo router?

That logic would be up to you to write and determine if anything gets overridden or if you are only calling 1 service then it is much easier