Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Prisma DMMF JsonFilter input has no fields #689

Closed
MichalLytek opened this issue May 13, 2020 · 5 comments
Closed

Prisma DMMF JsonFilter input has no fields #689

MichalLytek opened this issue May 13, 2020 · 5 comments
Labels
bug/2-confirmed We have confirmed that this is a bug. tech/typescript Issue for tech TypeScript. topic: json
Milestone

Comments

@MichalLytek
Copy link

Bug description

When I have really simple model:

model Post {
  uuid      String    @default(uuid()) @id
  title     String
  metadata  Json
}

For filter input types, for fields of type Json, it emits JsonFilter object type as field input type:

{
  "name": "PostScalarWhereInput",
  "fields": [
    {
      "name": "title",
      "inputType": [
        {
          "isList": false,
          "isRequired": false,
          "kind": "scalar",
          "type": "String"
        },
        {
          "type": "StringFilter",
          "isList": false,
          "isRequired": false,
          "kind": "object"
        }
      ],
      "isRelationFilter": false
    },
    {
      "name": "metadata",
      "inputType": [
        {
          "isList": false,
          "isRequired": false,
          "kind": "scalar",
          "type": "Json"
        },
        {
          "type": "JsonFilter",
          "isList": false,
          "isRequired": false,
          "kind": "object"
        }
      ],
      "isRelationFilter": false
    }
  ],
  "isWhereType": true,
  "atLeastOne": false
}

But the generated JsonFilter type has no fields which results in empty input type class generated by TypeGraphQL integration:

{
  "name": "JsonFilter",
  "fields": [],
  "atLeastOne": false
}

Environment & setup

  • OS: [e.g. Mac OS, Windows, Debian, CentOS, ...] Windows 10 x64
  • Database: [PostgreSQL, MySQL, MariaDB or SQLite] Postgres
  • Prisma version: [Run prisma -v to see your Prisma version] 2.0.0-beta.5
  • Node.js version: [Run node -v to see your Node.js version] 13.12
@prisma/cli          : 2.0.0-beta.5
Current platform     : windows
Query Engine         : query-engine 0c2ec197653b278b2978845ef958db88824cd82e (at D:\#Projekty\typegraphql-prisma\experiments\node_modules\@prisma\cli\query-engine-windows.exe)
Migration Engine     : migration-engine-cli 0c2ec197653b278b2978845ef958db88824cd82e (at D:\#Projekty\typegraphql-prisma\experiments\node_modules\@prisma\cli\migration-engine-windows.exe)
Introspection Engine : introspection-core 0c2ec197653b278b2978845ef958db88824cd82e (at D:\#Projekty\typegraphql-prisma\experiments\node_modules\@prisma\cli\introspection-engine-windows.exe)
Format Binary        : prisma-fmt 0c2ec197653b278b2978845ef958db88824cd82e (at D:\#Projekty\typegraphql-prisma\experiments\node_modules\@prisma\cli\prisma-fmt-windows.exe)
@timsuchanek timsuchanek added the kind/discussion Discussion is required. label May 13, 2020
@timsuchanek
Copy link
Contributor

Thanks for reporting @MichalLytek!
For now, this is just a placeholder until we have proper filters.

@schrobak
Copy link

Hi @timsuchanek!
Is it possible to disable generation of the JsonFilter. Or some workaround to tell the generator it should skip specific fields from the model?
I know this is beta, but thought this json feature is actually usable. Unfortunately it's not at the moment.

@janpio janpio added kind/feature A request for a new feature. topic: json kind/improvement An improvement to existing feature and code. and removed kind/discussion Discussion is required. kind/feature A request for a new feature. labels May 14, 2020
@ianwensink
Copy link

Is there any news on this? It is causing a blocking issue for us with an existing database. I have a field of the Json type, so it will break the API. Even when I don't enable the filter for that field (I don't need it) in Nexus, it still results in an exception. Would be great if we can disable this placeholder or workaround it. Now I have to write custom queries in Nexus for normal crud operations.

@timsuchanek timsuchanek added bug/2-confirmed We have confirmed that this is a bug. and removed kind/improvement An improvement to existing feature and code. labels Jun 17, 2020
@timsuchanek timsuchanek added this to the 2.1.0 milestone Jun 17, 2020
@timsuchanek timsuchanek added the tech/typescript Issue for tech TypeScript. label Jun 17, 2020
@timsuchanek
Copy link
Contributor

timsuchanek commented Jun 19, 2020

Thanks a lot for your input everyone!
It turned out, that we already had not and equals available, we just didn't expose them!

So from now on, you can filter by equality of a Json blob!

Closed by prisma/prisma@3a1a4fb

@timsuchanek
Copy link
Contributor

timsuchanek commented Jun 19, 2020

This is how you can filter for Json now:

  const result = await prisma.post.findMany({
    where: {
      jsonData: [
        {
          array1key: 'array1value',
        },
      ],
    },
  })

https://github.com/prisma/prisma/blob/3a1a4fb2f1c739febc7f7509c45ecc0eb64cdb08/src/packages/client/src/__tests__/runtime-tests/blog-env-postgresql/index.js#L239

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug/2-confirmed We have confirmed that this is a bug. tech/typescript Issue for tech TypeScript. topic: json
Projects
None yet
Development

No branches or pull requests

5 participants