Graphcool / graphcool-framework

Apache License 2.0
1.78k stars 130 forks source link

Payload does not change on operationBefore (but works on local) #450

Open marktani opened 6 years ago

marktani commented 6 years ago

Issue by matart15 Saturday Jan 06, 2018 at 02:59 GMT Originally opened as https://github.com/graphcool/prisma/issues/1521


For bug reports, please fill in the next sections:

Current behavior

graphcool.yml

# In the types.graphql you define your data schema
types: ./types.graphql

functions:
  # client auth
  signupClient:
    type: operationBefore
    operation: Client.create
    handler:
      code: src/client-auth/signup.js
src/client-auth/signup.js

export default async (event) => {

    // create password hash
    const salt = bcrypt.genSaltSync(SALT_ROUNDS)
    const hash = await bcrypt.hash(password, salt)

    const s  = {
      ...event.data,
      passwordHash: hash
    }

    console.log('_____________', s)
    return {
      data: s
    }
}
mutation 

createClient(
    name: "AAA",
    type: "admin",
    email: "asdf1@asdf.com",
    passwordHash: "qwerqwer"
  ) {
    id
    email
    passwordHash
  }

it works perfect on local.

local response 

{
  "data": {
    "createUser": {
      "id": "cjc2pm1xx00i80141co1u3rdw",
      "email": "qwer1@qwer.com",
      "passwordHash": "$2a$10$GfCPN1WJ.2v3ZlHvYGPo6OVtlDtjIEqybCX8O7NsNWXdz.OdXroj6"
    }
  }
}

does not work on shared-ap-northeast-1 passwordHash gets old value.

shared-ap-northeast-1 response 

{
  "data": {
    "createClient": {
      "id": "cjc2r1xqn5m9j0103ydzgnn83",
      "email": "asdf@asdf.com",
      "passwordHash": "qwerqwer"
    }
  }
}

shared-ap-northeast-1 server log shows bcrypt is working and hash value is changed.

{
      "2018-01-06T02:48:03.140Z": "_____________ { email: 'asdf@asdf.com',\n  id: 'cjc2r1xqn5m9j0103ydzgnn83',\n  name: 'AAA',\n  passwordHash: '$2a$10$zfLNagkDeAKoFUe6RPMOKePIlzfVc31SpGksvMNCelsudYR4uAsqW',\n  type: 'admin' }"
 }
matart15 commented 6 years ago

any update on this?