Skip to content

Commit 2c7ecf2

Browse files
committed
remove node-fetch import
1 parent 5aed94f commit 2c7ecf2

File tree

1 file changed

+20
-30
lines changed

1 file changed

+20
-30
lines changed

codegen/schema/get-gql-schema.mjs

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
1-
import fetch from 'node-fetch';
2-
import {
3-
getIntrospectionQuery,
4-
} from 'graphql';
1+
import { getIntrospectionQuery } from "graphql";
52

6-
export async function getGqlSchema ({ moduleName, cache, url, token }) {
3+
export async function getGqlSchema({ moduleName, cache, url, token }) {
74
try {
8-
const introspectionQuery = getIntrospectionQuery()
5+
const introspectionQuery = getIntrospectionQuery();
96

10-
const response = await fetch(
11-
url,
12-
{
13-
method: 'POST',
14-
headers:
15-
token
16-
? {
17-
'Content-Type': 'application/json',
18-
Authorization: `Bearer ${token}`
19-
}
20-
: {
21-
'Content-Type': 'application/json'
22-
},
23-
body: JSON.stringify({ query: introspectionQuery })
24-
}
25-
)
7+
const response = await fetch(url, {
8+
method: "POST",
9+
headers: token
10+
? {
11+
"Content-Type": "application/json",
12+
Authorization: `Bearer ${token}`,
13+
}
14+
: {
15+
"Content-Type": "application/json",
16+
},
17+
body: JSON.stringify({ query: introspectionQuery }),
18+
});
2619

27-
const { data: schema, errors } = await response.json()
20+
const { data: schema, errors } = await response.json();
2821

2922
if (errors) {
30-
throw new Error(errors
31-
.map(err => "- " + err.message)
32-
.join('\n')
33-
)
23+
throw new Error(errors.map((err) => "- " + err.message).join("\n"));
3424
}
3525

36-
return { moduleName, cache, schema }
26+
return { moduleName, cache, schema };
3727
} catch (err) {
38-
console.error('failed to get gql schema', err)
39-
throw (err)
28+
console.error("failed to get gql schema", err);
29+
throw err;
4030
}
4131
}

0 commit comments

Comments
 (0)