Turns out because I'd just done too many solutions and got bogged down thinking it was more complicated than it was. The solution is that you need to call the result of the createHandler
function with the event,context,callback
args from the exported function. Below is what I did and it works:-
const neoSchema = new Neo4jGraphQL({
typeDefs,
driver: neo4j.getDriver,
resolvers,
});
const initServer = async () => {
return await neoSchema.getSchema().then((schema) => {
const server = new ApolloServer({
schema,
context: ({ event }) => ({ req: event }),
introspection: process.env.SLS_STAGE === 'dev',
});
return server.createHandler();
});
};
export const graphqlHandler = async (event, context, callback) => {
const serverHandler = await initServer();
return serverHandler(
{
...event,
requestContext: event.requestContext || {},
},
context,
callback
);
};
Hopefully this will assist someone else out there.