prisma-binding icon indicating copy to clipboard operation
prisma-binding copied to clipboard

UpdateMany${type} asks for ${type}UpdateManyMutationInput instead of ${type}UpdateInput

Open yukulelix opened this issue 5 years ago • 5 comments

The bug Hi there, I'm having some issues using an updateMany mutation with prisma binding :

prisma.mutation.updateManyReviews(
  {
    where: { key_in: keys },
    data: { analysisStatus: 'PENDING' }
  },
  '{ count }'
)

When the function runs, it's giving me this error :

Variable '$_v0_data' of type 'ReviewUpdateInput!' used in position expecting type 'ReviewUpdateManyMutationInput!'. (line 1, column 11):
mutation ($_v0_data: ReviewUpdateInput!, $_v1_where: ReviewWhereInput) {
         ^
(line 2, column 27):
 updateManyReviews(data: $_v0_data, where: $_v1_where) {
                         ^

But in the generated model, I have no trace of a ReviewUpdateManyMutationInput :

updateManyReviews(data: ReviewUpdateInput!, where: ReviewWhereInput): BatchPayload!

Versions (please complete the following information):

  • Connector: MySQL
  • Prisma Server: 1.27.4
  • other dependencies: prisma-binding

Thanks for your help !

yukulelix avatar Mar 05 '19 15:03 yukulelix

Hi @yukulelix

Can you please also share your datamodel so that I can try to reproduce this?

Also, we may transfer this to prisma bindings repository itself as it seems to be solely related to it.

pantharshit00 avatar Mar 06 '19 16:03 pantharshit00

Hi @pantharshit00, thanks for your help :) The related datamodel part is :

enum ReviewAnalysisStatusType {
  INITIAL
  PENDING
  DONE
}
type Review {
  id: ID! @unique
  key: String! @unique

  createdAt: DateTime!
  updatedAt: DateTime!

  publishedAt: String
  analysisStatus: ReviewAnalysisStatusType! @default(value: INITIAL)
}

The javascript function that produces the error is :

import { Prisma } from 'prisma-binding'
import typeDefs from '../../database/generated/prisma.graphql'

async function updateManyReviewsAnalysisStatus (keys, analysisStatus) {
    const db = new Prisma({
      typeDefs,
      endpoint: "endpoint",
      secret: "***"
    })
    return db.mutation.updateManyReviews(
      {
        where: { key_in: keys },
        data: { analysisStatus }
      },
      '{ count }'
    )
}

// Called like this 
updateManyReviewsAnalysisStatus(["key-one", "key-two"], "PENDING")

Thanks in advance !

yukulelix avatar Mar 11 '19 15:03 yukulelix

Any news on this @pantharshit00 ?

yukulelix avatar Mar 18 '19 08:03 yukulelix

Hi I'm getting a very similar error! Basically the production scheme is completely different to my development schema.. What's happening here?

nugoo1 avatar Jun 17 '19 14:06 nugoo1

I'm experiencing this as well, I'm passing data as the docs say to do, I don't see anything about UpdateManyMutationInput

the-simian avatar Nov 15 '19 03:11 the-simian