Neo4j with Apollo v4 and @as-integrations/aws-lambda

Hello friends.

Do you know integrate the new ApolloServer V4 with package integration of AWS (@as-integrations/aws-lambda) and Neo4j ?

I have try to execute in my lambda this code :

import { ApolloServer } from '@apollo/server';
import { startServerAndCreateLambdaHandler } from '@as-integrations/aws-lambda';
import DatabaseManage from '../services/database/DatabaseManage';
import { Neo4jGraphQL} from '@neo4j/graphql'


const typeDefs = `#graphql
  type NodeAymeric {
    hello: String
  }
`;

const resolvers = {
  NodeAymeric: {
    hello: () => 'world',
  },
};

const driver = DatabaseManage.driver ;

const neoShema = new Neo4jGraphQL({
  typeDefs,
  resolvers,
  driver})

  const initServer = async () => {
    return await neoShema.getSchema().then((schema) => {
        const server = new ApolloServer({
            schema,
        });
        return server;
    });
};

export const handler = async () => {
  const serverHandler = await initServer();
  return startServerAndCreateLambdaHandler(serverHandler)
};

My query.json:

{
    "version": "2",
    "httpMethod": "POST",
    "path": "/",
    "headers": {
      "content-type": "application/json"
    },
    "requestContext": {},
    "rawQueryString": "",
    "body": "{\"operationName\": null, \"variables\": null, \"NodeAymeric\": \"{ hello }\"}"
  }

When I invoke the function with serverless :

/user/me$ serverless invoke local -f function-create-nodeAymeric -p ./Request/query.json

I have : "undefined" and my node (NodeAymeric) is not created in data base.

Do you have an idea ?

Hi @Aymeric! I'm afraid this looks like more of a question about using an ApolloServer with @as-integrations/aws-lambda so you may have more luck asking in either of those communities.

That being said, it seems as though the query you are making would not be valid for the type definitions you provided. It looks as though you are attempting to query NodeAymeric nodes. If this is the case the way to do this with the provided type definitions is as follows:

query {
  nodeAymerics {
    hello
  }
}

However, your message suggests you are trying to create a NodeAymeric node. This could be achieved with the query below:

mutation {
  createNodeAymerics(input: {hello: "someValue"}) {
    nodeAymerics {
      hello
    }
  }
}

I hope this helps!

Thank you @LiamDoodson for your feedback.
Indeed my code could not work.
Now I better understand type definitions and resolve them.