Skip to content

Commit 5f0535f

Browse files
committed
Use node-fetch to make nock work for graphql-request
1 parent 0a815ec commit 5f0535f

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

packages/plugins/typescript/graphql-request/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"devDependencies": {
5151
"@graphql-codegen/testing": "1.18.3",
5252
"@graphql-tools/schema": "10.0.23",
53-
"graphql-request": "7.1.2"
53+
"graphql-request": "7.1.2",
54+
"node-fetch": "2.7.0"
5455
},
5556
"publishConfig": {
5657
"directory": "dist",
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { GraphQLClient } from 'graphql-request';
2+
import fetch from 'node-fetch'; // FIXME: using `node-fetch` temporarily because `graphql-request@7` uses native fetch, which `[email protected]` from `@graphql-codegen/testing` does not support
23
import { getSdk } from './graphql-request-sdk.js';
34

45
export function runExampleQuery(x: number, y: number) {
5-
const client = new GraphQLClient('http://localhost:4000/graphql');
6+
const client = new GraphQLClient('http://localhost:4000/graphql', { fetch });
67
const sdk = getSdk(client);
78
return sdk.Add({ x, y });
89
}

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6059,7 +6059,7 @@ [email protected]:
60596059
lodash "^4.17.21"
60606060
propagate "^2.0.0"
60616061

6062-
node-fetch@^2.5.0, node-fetch@^2.6.1, node-fetch@^2.7.0:
6062+
node-fetch@2.7.0, node-fetch@^2.5.0, node-fetch@^2.6.1, node-fetch@^2.7.0:
60636063
version "2.7.0"
60646064
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d"
60656065
integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==

0 commit comments

Comments
 (0)