How to send operationName as part of the request query?

When I was setting up a new federated graph in studio, I noticed that Apollo’s own queries to its servers have the operation name as part of the query params,
e.g. graphql?operationName=SomeOperation.
This is dope in several ways and I want to enable it for our application. Looking through the client options, I didn’t see anything obvious that would enable this behavior. How do?

2 Likes

Hi @Patrick_Hansen, take a look at the docs for Apollo Link. Based on your post, I think that might give you what you’re looking for - let me know if you have any follow up questions!

1 Like

Specifically, take a look at the docs for HTTP Link’s uri property:

Can also be a function that accepts an Operation object and returns the string URL to use for that operation.

Your uri function can take operation.operationName and append it to the uri for each request. I use this too – very useful for logging and debugging!

2 Likes