Using node-fetch with apollo-link-http

Mae Capozzi · May 23, 2019

I'm building a Gatsby app that consumes data from a GraphQL service with the help of apollo-client and TypeScript. Because Gatsby creates static assets at build time, I needed a data-fetching tool that would work on the client-side and the server-side. apollo-client recommends using node-fetch for the task.

When I installed node-fetch and tried it out, I got this TypeScript error:


Naturally, I installed @types/node-fetch. Rather than solving my problem, it led me to another one:


This error is basically saying that I have two different type declarations for fetch, and they are incompatible. In other words, apollo-client's type declaration for fetch doesn't match node-fetch's.

Thanks to a few hours of combing through Github issues, I found a solution hidden deep in the comments. In any d.ts file in your project, add:


I've opened an issue on the repo to add this information to the docs. You can find it here.

Continue Reading

aiobservabilitydeveloper-tools

AI agents removed the friction from writing telemetry

I used to avoid adding telemetry because it felt like tedious busywork. Now with Claude handling the OpenTelemetry boilerplate, I'm instrumenting everything.

Read Post