kriasoft/graphql-starter-kit

Using with bcrypt get failed to fetch error

Khangeldy opened this issue · 4 comments

I don't know why but when i call bcrypt methods in mutation even just for logging i get error. I testing in graphiql. Bcrypt last version. I tested ON seperate file bcrypt. It works fine.

Looks like you should provide more info like code snippet and error message..

In server i don't have any output logs. When it reaches to bcrypt call, server rejects this request without any response and not execute after bcrypt lines. In client i see only failed to fetch error.

Currently slice of code looks like this

export const createUser = mutationWithClientMutationId({
  name: 'CreateUser',
  inputFields,
  outputFields,
  async mutateAndGetPayload(input, context) {
    const { data, errors } = validate(input, context);

    if (errors.length) {
      throw new ValidationError(errors);
    }

    console.log('Requested by client');

    data.password = await bcrypt.hash('testing', 2); // below this nothing executed
    console.log(data.password);
    return data;
    

    const rows = await db
      .table('users')
      .insert(data)
      .returning('id');

    console.log('rows = ', rows);

    return context.userById.load(rows[0]).then(user => ({ user }));
    // return context.userById.load("VXNlcjozOGZhMGY2YS1iYTIzLTExZTctYTAyZi1mYmQ0NTNlOTQ2YjA=").then(user => ({ user }));
  },
});

Switched to bcryptjs.

@Khangeldy perhaps some native dependency of bcrypt is missing. Or, it's not compatible with node-alpine image, you can tweak .Dockerfile in the root of the project to include missing dependencies (e.g. apk add --no-cache <package>) or change node:8.9.3-alpine to node:8.9.3.