Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make custom resolver for create users #5216

Open
YashvardhanKumar opened this issue Jun 8, 2024 · 0 comments
Open

How to make custom resolver for create users #5216

YashvardhanKumar opened this issue Jun 8, 2024 · 0 comments
Labels
feature request New feature or request

Comments

@YashvardhanKumar
Copy link

I am not able to find a way out how can I make custom resolver on create{TypeName} autogenerated mutation function so that i can add password hashing in it. For example i have a field named "password", I pass the password to the field and hash it and store the hash in the password field. So for that i made a custom resolver but failed to do since the older graphql-neo4j-js had a function named "neo4jgraphql".

createUsers: async (
      some: any,
      params: any,
      ctx: any,
      resolverInfo: any,
    ) => {
      console.log(params);
      const dat = JSON.parse(JSON.stringify(params.input[0]))
      console.log({dat});
      
      
      // params.hash = await argon2.hash( params.hash );
      const findUser = await ctx.executionContext.executeQuery(`
      
        CALL {
        CREATE (createe:User)
        SET
        createe.id = "${dat.id}",
        createe.name = "${dat.name}",
        createe.email = "${dat.email}",
        createe.username = "${dat.username}"
        RETURN createe
        }
        RETURN createe { .id, .name, .email, .username } AS data`);
      // if ( findUser.records.length > 0 ) {
      //   throw new ApolloError( 'This user already exists', "200", [
      //     'user_already_exists',
      //   ] );
      // }

      console.log(findUser);
      let info: CreateInfo = {
        nodesCreated: params.input.length,
        relationshipsCreated: 0,
      };
      let a: CreateUsersMutationResponse = { info, users: findUser };
      console.log(a);

      return a;
      // return neo4jgraphql( obj, params, ctx, resolveInfo, true );
    },

I request the team to please make an alternative function of the "neo4jgraphql" function or if there is any, please guide me for the same. Since the package has deprecated, i am not able to use it and i can't find any supporting threads as of how i can do it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant