Prisma1: Prisma Client 1.17 create mutation generates 2 records

Created on 16 Sep 2018  路  8Comments  路  Source: prisma/prisma1

Describe the bug
Prisma Client 1.17 create mutation generates 2 records

To Reproduce
Steps to reproduce the behavior:

  1. Clone https://github.com/prisma/prisma-examples
  2. Go to node-graphql
  3. Follow the instructions to setup
  4. Run createDraft mutation
  5. You will have 2 records returned by the drafts query

Versions:

  • OS: OS X High Sierra
  • prisma CLI: prisma/1.17.0-beta.11 (darwin-x64) node-v8.11.3
  • Prisma Server: 1.17-beta-1
bu2-confirmed

All 8 comments

I can reproduce this.

For anyone trying to reproduce this locally, you will need to follow slightly different instructions and create a user before running createDraft.

Interestingly enough, I cannot reproduce this anymore after some while, without changing anything.
If I then deploy a new service, I cannot reproduce it at all in the new service.

This seems like a very subtle bug or even a problem with the environment setup. To start looking into this, we require a consistent and reliable reproduction, so let us know if you found one.

I got this same issue and seems so hopefully its consistently reproducible with my repo.

To Reproduce

  1. Clone https://github.com/addstar34/labeouf
  2. cd into packages/apollo-server-api
  3. run yarn install
  4. run docker-compose up -d
  5. run prisma deploy
  6. run prisma generate
  7. yarn start
  8. using graphql playground create a mutation for createTodo
  9. using graphql playground query todos and you'll see 2 todos

Versions:

Thanks @addstar34, I can once again confirm your reproduction. Looking into this.

@marktani I think I found out what the problem is here, the resolvers need to use async/await with the call to prisma. Eg:

async function createTodo(_parent, args, context, _info) {
  return await context.prisma.createTodo({
    title: args.title,
    description: args.description,
  })
}

I think the issue stems from the docs as I just copy pasted the resolvers from here as my starting point which don't use async/await: https://www.prisma.io/docs/1.17/get-started/03-build-graphql-servers-with-prisma-e001/#implement-resolver-functions

@addstar34 : You should be able to do the following as well, if this executes twice, then that is a bug. We will look into it. Thanks!

function createTodo(_parent, args, context, _info) {
  return context.prisma.createTodo({
    title: args.title,
    description: args.description,
  })
}

Closing this in favor of #3210, which seems to be a bug in Prisma core.

I've created Mysql DB including Trigger to insert into "audit" table. But every time I insert(Mutation) a record into primary table on the "audit" table insert or duplicate the record. I'd appreciate if this is the same Prisma Core bug you've been talking about.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

schickling picture schickling  路  3Comments

marktani picture marktani  路  3Comments

schickling picture schickling  路  3Comments

marktani picture marktani  路  3Comments

sorenbs picture sorenbs  路  3Comments