Skip to content

Commit c07c5ea

Browse files
committed
chore: Cleanup introspection error handling
1 parent ae3909b commit c07c5ea

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

scripts/generate-gql-types.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ export async function generateGqlTypes(fetch: ServerSideFetch = app.build()) {
1616
consola.info("Generating GraphQL types...");
1717
const introspection = await introspect(fetch);
1818

19-
if (introspection.errors) {
20-
console.error("Introspection errors:", introspection.errors);
21-
throw Error("Introspection failed", { cause: introspection.errors });
22-
}
23-
2419
const {
2520
queryType,
2621
mutationType,
@@ -147,7 +142,12 @@ async function introspect(fetch: ServerSideFetch): Promise<any> {
147142
method: "POST",
148143
});
149144
const res = await fetch(request);
150-
if (res.ok) return await res.json();
145+
if (!res.ok)
146+
throw Error("Introspection request failed: " + (await res.text()));
147+
148+
const json: any = await res.json();
149+
if (json.errors)
150+
throw Error("Introspection request failed: " + JSON.stringify(json.errors));
151151

152-
throw Error("Introspection request failed: " + (await res.text()));
152+
return json;
153153
}

0 commit comments

Comments
 (0)