Skip to content

Commit 794dd46

Browse files
authored
fix: issue making GraphQL Apollo Sandbox inaccessible with TypeScript (#155)
1 parent bc26b19 commit 794dd46

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

ts/graphql/graphql/graphql.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { api } from "encore.dev/api";
2+
import log from "encore.dev/log";
23
import { ApolloServer, HeaderMap } from "@apollo/server";
34
import { readFileSync } from "node:fs";
45
import resolvers from "./resolvers";
@@ -25,12 +26,20 @@ export const graphqlAPI = api.raw(
2526
}
2627
}
2728

29+
let body: unknown;
30+
31+
try {
32+
body = await json(req);
33+
} catch (error) {
34+
log.error(error);
35+
}
36+
2837
// More on how to use executeHTTPGraphQLRequest: https://www.apollographql.com/docs/apollo-server/integrations/building-integrations/
2938
const httpGraphQLResponse = await server.executeHTTPGraphQLRequest({
3039
httpGraphQLRequest: {
3140
headers,
3241
method: req.method!.toUpperCase(),
33-
body: await json(req),
42+
body,
3443
search: new URLSearchParams(req.url ?? "").toString(),
3544
},
3645
context: async () => {

0 commit comments

Comments
 (0)