question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Graphql requests are not monitoring friendly

See original GitHub issue

Intended outcome:

Be able to monitor graphql requests through a third party monitoring library.

Actual outcome:

Third party monitoring library override global fetch to gather data on each request. Since createHttpLink keep a reference to fetch (code), if global fetch is instrumented after createHttpLink execution then graphql requests can’t be instrumented.

How to reproduce the issue:

with a simple fetch override:

const originalFetch = window.fetch;
window.fetch = function () {
  console.log("request instrumented", arguments[0]);
  return originalFetch.apply(this, arguments);
};

if executed before ApolloClient initialization, graphql requests are logged if executed after ApolloClient initialization, graphql requests are not logged

Versions

master

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
arminrosucommented, Dec 5, 2022

That’s also interesting and something that might be worth getting more detail on - what issues did you see? Is this a bug in Apollo Client?

I’ll get back to you once I give this one another shot. I haven’t had time to look into it closely yet.

1reaction
bignimbuscommented, Nov 7, 2022

Hi @bcaudan, thanks for your patience! Would passing the overridden fetch function via the fetch option in HTTP Link per these docs address the issue you’re describing?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Securing Your GraphQL API from Malicious Queries
Letting this kind of query through is very bad, since it exponentially increases the amount of objects loaded and will crash your entire...
Read more >
Solved: Synthetic monitor for graphql - Dynatrace Community
Hello everyone, I will create a synthetic monitor for API based on graphql. Does Dynatrace support queries and / or mutation for this...
Read more >
A Guide on How to Monitor GraphQL APIs - Atatus
A GraphQL API server parses GraphQL API requests on the server-side and retrieves the appropriate data from backend services and data stores ...
Read more >
Comparing REST and GraphQL Monitoring Techniques
GraphQL uses a single HTTP endpoint for all functions and allows different requests to route to the appropriate location in the GraphQL server....
Read more >
Is GraphQL monitoring still hard - now that enabling tracing is ...
It was doable, but not entirely simple. Essentially we create a span on each incoming request, then retrieve that in the resolvers so...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found