Datadog RUM attaches headers to outgoing fetch and XHR requests to be able to link together traces. When using Apollo's HTTPLink, this functions correctly, but it doesn't with BatchHTTPLink.
This was previously reported as an issue and fixed for HTTPLink in PR #8603 but the same fix needs to be applied to BatchHTTPLink.
# Assuming you have nvm installed, if not skip this step or install the latest node version
nvm install
corepack enable
yarn install
yarn start- Open
localhost:9000in a browser - open the network tab
- You should see a request to
http://localhost:9000/graphql - Examine the request headers for the request and see that there are no
x-datadog-headers attached.
- Change the client passed to the
ApolloProviderinapp/Component.jsto useunbatchedClient - Refresh the browser
- Examine the request headers again for the
/graphqlrequest - There are now several
x-datadog-headers attached to the request
By passing in a custom function for fetch which forces the fetch to be reevaluated, we can get around the issues with BatchHTTPClient.
- Change the client passed to the
ApolloProviderinapp/Component.jsto usebatchedClientWithHack - Refresh the browser
- Examine the request headers again for the
/graphqlrequest - There are now several
x-datadog-headers attached to the request