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
}
prisma -v to see your Prisma version] 2.0.0-beta.5node -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)
Thanks for reporting @MichalLytek!
For now, this is just a placeholder until we have proper filters.
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.
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.
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 https://github.com/prisma/prisma/commit/3a1a4fb2f1c739febc7f7509c45ecc0eb64cdb08
This is how you can filter for Json now:
const result = await prisma.post.findMany({
where: {
jsonData: [
{
array1key: 'array1value',
},
],
},
})
Most helpful comment
Thanks a lot for your input everyone!
It turned out, that we already had
notandequalsavailable, we just didn't expose them!So from now on, you can filter by equality of a Json blob!
Closed by https://github.com/prisma/prisma/commit/3a1a4fb2f1c739febc7f7509c45ecc0eb64cdb08