Showing results for 
Search instead for 
Did you mean: 

How to fetch from neo4j database inside custom resolver

Node Link

Could someone help me understand how to reach out to my neo4j database to check if a user exists inside my custom resolver for login?

 Mutation: {
    register: async (_, { id, email, password }, context, info) => {
      const hashedPassword = await bcrypt.hash(password, 10);
      return neo4jgraphql(_, { id, email, password }, context, info);
    login: async (_, { email, password }, context, info) => {

      const user  =  //check neo4j database for existing user to log in
      if (!user) {
        return "user not found";

      const valid = await, user.password);
      if (!valid) {
        return null;

      const refreshToken = sign(
        { userId:, count: user.count },
          expiresIn: "30d"
      const accessToken = sign({ userId: }, ACCESS_TOKEN_SECRET, {
        expiresIn: "1day"

      context.res.cookie("refresh-token", refreshToken);
      context.res.cookie("access-token", accessToken);

      return user;

I'm not sure how to reach the database when you need more than simply calling neo4jgraphql() in the return of the resolver.

Nodes 2022
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.