Hello friends.
I'm working with AWS Lambda using NodeJS. I had managed to create a GraphQL server with the Neo4J generated schema - that is until getting the schema turned into an Async function call.
My old code
import { ApolloServer } from 'apollo-server-lambda';
import { Neo4jGraphQL } from '@neo4j/graphql';
const neoSchema = new Neo4jGraphQL({
typeDefs,
driver: neo4j.getDriver,
resolvers,
});
const apollo_server = new ApolloServer({
schema: neoSchema.schema,
introspection: process.env.SLS_STAGE === 'dev',
context: ({ event, context, express }) => {
console.log('event', event);
return {
headers: event.headers,
functionName: context.functionName,
event,
context,
expressRequest: express.req,
};
},
} as any);
export const graphqlHandler = apollo_server.createHandler();
This worked like a dream but (since upgrading) I can no longer access the schema with dot notation. I have to do something like const schema = await neoSchema.getSchema()
. That's fine but because of the way Lambda's work and potentially my lack of knowledge if I put any kind of async await or promise in the way of the createHandler()
on the apollo_server
- the Lambda does not work and gives me a 502.
So I'm hoping someone cleverer than me has a workaround for this. For ref below are my package dependency versions
"dependencies": {
"@neo4j/graphql": "^3.1.0",
"@neo4j/graphql-plugin-auth": "^1.0.0",
"apollo-server-lambda": "^3.6.7",
"aws-sdk": "^2.1067.0",
"class-validator": "^0.13.2",
"graphql": "^16.4.0",
"lodash": "^4.17.21",
"neo4j-driver": "^4.4.2",
"reflect-metadata": "^0.1.13",
"short-unique-id": "^4.4.4",
"type-graphql": "^1.1.1",
"uuid": "^8.3.2"
},