Graphql-request - Cannot find name 'RequestInit'

I’ve been using graphql-request with 8base “Custom functions” for a long time.

Haven’t needed to touch anything in my backend for a while, but did a small fix today and I’m now getting the following error when I run 8base deploy

error: Compilation failed:
Error: node_modules/graphql-request/dist/src/index.d.ts (11,18): Cannot find name 'Headers'.
Error: node_modules/graphql-request/dist/src/index.d.ts (22,14): Cannot find name 'Headers'.Error: node_modules/graphql-request/dist/src/types.d.ts (8,14): Cannot find name 'RequestInit'.Error: node_modules/graphql-request/dist/src/types.d.ts (10,12): Cannot find name 'RequestInit'.Error: node_modules/graphql-request/dist/src/types.d.ts (11,19): Cannot find name 'RequestInit'.Error: node_modules/graphql-request/dist/src/types.d.ts (12,13): Cannot find name 'RequestInit'.Error: node_modules/graphql-request/dist/src/types.d.ts (13,16): Cannot find name 'RequestInit'.Error: node_modules/graphql-request/dist/src/types.d.ts (14,16): Cannot find name 'RequestInit'.
Error: node_modules/graphql-request/dist/src/types.d.ts (15,22): Cannot find name 'RequestInit'.
Error: node_modules/graphql-request/dist/src/types.d.ts (16,17): Cannot find name 'RequestInit'.

I tried updating the 8base cli, I tried updating graphql-request, I tried installing graphql and googled the issue.

I found this related GitHub issue: https://github.com/prisma-labs/graphql-request/issues/26

The issue seems to be because it’s a node environment (not a browser) and the index.d.ts file is using Dom

constructor(url: string, options?: Dom.RequestInit);

Not sure why this was working before, but is no longer working? Is there a new recommended tool for graphQL requests with 8base CLI?

Found a reference in some of the docs to ctx.api.gqlRequest

Trying to switch to that, but ran into apermissions error with it.

1 Like