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

jsonProtocol: in argument of filter types does not accept scalars #18549

Closed
SevInf opened this issue Mar 29, 2023 · 1 comment · Fixed by prisma/prisma-engines#3890
Closed
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/engines Issue for tech Engines. topic: in topic: jsonProtocol
Milestone

Comments

@SevInf
Copy link
Contributor

SevInf commented Mar 29, 2023

Bug description

When GraphQL protocol is used, we accept scalar fields for in arguments because this shortcut is implemented on the client. With jsonProtocol, client-side shortcut no longer exists and engine rejects this code.

How to reproduce

  1. Run the provided code. Get the validation error:
    Argument `in`: Invalid value provided. Expected String[], provided String.
    
  2. Remove jsonProtocol preview feature from the schema, re-generate code and re-run the schema. It will finish without an error.

Expected behavior

Identical behavior regardless of the protocol

Prisma information

generator client {
  provider        = "prisma-client-js"
  output          = "../node_modules/.prisma/client"
  previewFeatures = ["jsonProtocol"]
}

datasource db {
  provider = "sqlite"
  url      = "file:./dev.db"
}

model User {
  id String @id
}
await prisma.user.findFirst({
    where: {
      id: { in: '123' },
    },
  })

Protocol request:

{
  "modelName": "User",
  "action": "findFirst",
  "query": {
    "arguments": {
      "where": {
        "id": {
          "in": "123"
        }
      }
    },
    "selection": {
      "$composites": true,
      "$scalars": true
    }
  }
}

Environment & setup

  • OS: any
  • Database: any
  • Node.js version: any

Prisma Version

4.11.0+
@SevInf SevInf added bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. tech/engines Issue for tech Engines. topic: in topic: jsonProtocol labels Mar 29, 2023
@jkomyno jkomyno added the team/client Issue for team Client. label Apr 3, 2023
@janpio
Copy link
Member

janpio commented Apr 14, 2023

Current workaround until this is fixed:
Replace id: { in: '123' }, with either id: "123" or id: { in: ["123"] }.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. tech/engines Issue for tech Engines. topic: in topic: jsonProtocol
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants