Derek Kershner
03/26/2022, 4:28 PMapollo-server-errors
work out of the box (because apollo
uses graphql.js). ESM now works, and my package size dropped by ~1.8MB, which made cold starts about half as long.
Happy to share more if it is interesting.thdxr
03/26/2022, 4:33 PMthdxr
03/26/2022, 4:34 PMDerek Kershner
03/26/2022, 4:37 PMDerek Kershner
03/26/2022, 4:38 PMDerek Kershner
03/26/2022, 4:40 PMDerek Kershner
03/26/2022, 4:41 PMthdxr
03/26/2022, 4:49 PMDerek Kershner
03/26/2022, 5:01 PMDerek Kershner
03/26/2022, 5:06 PMgraphql.js
, rather than Helix as the primary framework (whenever you make the docs). When you told me this, I looked up Helix, compared to Apollo, and wanted maturity. If I had looked up graphql.js
, and noticed apollo
used it, I would have been MUCH more inclined to do this earlier.
I also saw Express on the Helix example when I looked it up and that was also a bad taste.thdxr
03/26/2022, 5:09 PMthdxr
03/26/2022, 5:09 PMthdxr
03/26/2022, 5:10 PMthdxr
03/26/2022, 5:10 PMDerek Kershner
03/26/2022, 5:12 PMgraphql-compose
for these types of purposes, but my experience has been mixed. It definitely works. I don’t have experience with Helix to compare.Derek Kershner
03/26/2022, 5:15 PMDerek Kershner
03/26/2022, 5:22 PMthdxr
03/26/2022, 6:34 PMDerek Kershner
03/26/2022, 7:12 PMgraphql
15 to 16 (resolveType for unions)thdxr
03/29/2022, 1:50 AMDerek Kershner
03/29/2022, 4:01 PMconst handler: APIGatewayProxyHandlerV2WithJWTAuthorizer = async (
event,
context
) => {
const graphqlContext: LambdaContextFunctionParams<
DataLoaders,
undefined
> = {
event,
context,
express: undefined,
loaders: dataLoaders,
};
if (!event.body) {
throw new Error("No body");
}
const parsedBody = JSON.parse(event.body);
graphQlLogger.log("Request started! Query:\n" + parsedBody.query, {
label: "handler",
});
const response = await graphql({
schema,
source: parsedBody.query,
contextValue: graphqlContext,
variableValues: parsedBody.variables,
});
return {
statusCode: 200,
body: JSON.stringify(response),
headers: {
"Content-Type": "application/json",
},
};
};
Derek Kershner
03/29/2022, 4:03 PMDerek Kershner
03/29/2022, 4:05 PMschema
and dataLoaders
are instantiated outside the handler (so that it only fires on cold start).thdxr
03/29/2022, 4:35 PMDerek Kershner
03/29/2022, 9:28 PM