Closed nizamiza closed 2 years ago
Hello @Hazeman28
Sorry for the late reply here. Can you still reproduce this with 2.28? Also, try passing where: locale ? { locale } : undefined
instead of where: locale ? { locale } : {},
If you can still reproduce this, please share a sql dump of these tables which we can use in a reproduction.
Hello @Hazeman28
Sorry for the late reply here. Can you still reproduce this with 2.28? Also, try passing
where: locale ? { locale } : undefined
instead ofwhere: locale ? { locale } : {},
If you can still reproduce this, please share a sql dump of these tables which we can use in a reproduction.
Hi, @pantharshit00 👋
Thanks for replying. I've tested locale ? { locale } : {}
vs locale ? { locale } : undefined
, but issue still persists.
I've also upgraded to v2.28
, but I'm still having the same problem. I've encountered this issue on another entity model in our project. I will describe details below.
Fetching single article works as expected:
query {
article(id: 1) {
id
categories {
title
}
subcategories {
title
}
}
}
Problem appears when fetching many articles:
query {
articles(filter: { perPage: 3 }) {
data {
id
categories {
title
}
subcategories {
title
}
}
}
}
As you can see, first and second articles have empty categories
, while fetching them individually returns full data.
My current workaround is to fetch categories and subcategories separately, same idea has been applied to the Project
entity as well:
I've updated prisma to version 3.3.0
. Issue still persists.
Issue still persists on version 3.5.0
.
Resolved in 3.7.0
Bug description
Not sure if I'm missing something or there is a bug.
I have a basic localization design for a
Project
entity (including only relevant parts of the schema):Prisma schema
```prisma model Partner { revisionId BigInt @id @default(autoincrement()) @map(name: "revision_id") id Int @default(autoincrement()) createdAt DateTime @default(now()) @map(name: "time") @db.Timestamptz(6) updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6) name String logo String? projectPartnerTypes ProjectPartnerType[] @@map(name: "audit_organization") } model Project { id BigInt @id @default(autoincrement()) createdAt DateTime @default(now()) @map(name: "created_at") @db.Timestamptz(6) updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6) published Boolean @default(false) translations ProjectTranslation[] @@map(name: "projects") } model ProjectPartnerType { id BigInt @id @default(autoincrement()) createdAt DateTime @default(now()) @map(name: "created_at") @db.Timestamptz(6) updatedAt DateTime @default(now()) @updatedAt @map("updated_at") @db.Timestamptz(6) priority Int @default(1) name String projectTranslationId BigInt @map("project_translation_id") projectTranslation ProjectTranslation? @relation(fields: [projectTranslationId], references: [id]) partners Partner[] @@map(name: "project_partner_types") } model ProjectTranslation { id BigInt @id @default(autoincrement()) projectId BigInt @map(name: "project_id") locale Locale name String contactEmail String? @map(name: "contact_email") partnerTypes ProjectPartnerType[] project Project? @relation(fields: [projectId], references: [id]) @@unique([projectId, locale]) @@map(name: "project_translations") } ```I have a resolver for the
Project
entity:GraphQL resolver
```typescript project: async ( _root: any, { id, published, locale }: QueryProjectArgs ): PromiseApplication has 2 locales:
sk-SK
andcs-CZ
. And if you don't pass thelocale
param to this resolver, it should return project with all translations. Which it does, except it doesn't resolve nestedpartners
inclusion for all translations, it does so only for the last element of the resultedproject.translations
array. Below are sample queries with their results:1. When
locale
is specifiedResult
```json { "data": { "project": { "translations": [ { "id": 39, "partnerTypes": [ { "id": 108, "partners": [ { "id": 5, "name": "Johns and Sons" }, { "id": 12, "name": "Pollich - Zieme" }, { "id": 14, "name": "Grant, Cole and Waelchi" } ] }, { "id": 109, "partners": [ { "id": 1, "name": "Willms - Renner" }, { "id": 4, "name": "Kiehn, Mante and Greenholt" }, { "id": 6, "name": "Miller, Kohler and Doyle" }, { "id": 9, "name": "Goodwin - Stokes" }, { "id": 10, "name": "Mayert - Morissette" }, { "id": 13, "name": "King - Bergnaum" }, { "id": 17, "name": "Morissette - Grimes" } ] }, { "id": 110, "partners": [ { "id": 7, "name": "Schaden and Sons" }, { "id": 16, "name": "Medhurst Group" }, { "id": 18, "name": "Huels - Lemke" } ] } ] } ] } } } ```Partner type ids:
108
,109
,110
.2. When
locale
is not specifiedSame query without
locale
param:Result
```json { "data": { "project": { "translations": [ { "id": 39, "partnerTypes": [ { "id": 108, "partners": [] }, { "id": 109, "partners": [] }, { "id": 110, "partners": [] } ] }, { "id": 40, "partnerTypes": [ { "id": 111, "partners": [] }, { "id": 112, "partners": [ { "id": 1, "name": "Willms - Renner" }, { "id": 4, "name": "Kiehn, Mante and Greenholt" }, { "id": 5, "name": "Johns and Sons" }, { "id": 6, "name": "Miller, Kohler and Doyle" }, { "id": 8, "name": "Reynolds, Vandervort and Abbott" }, { "id": 9, "name": "Goodwin - Stokes" }, { "id": 10, "name": "Mayert - Morissette" }, { "id": 11, "name": "Schinner - Spencer" }, { "id": 12, "name": "Pollich - Zieme" }, { "id": 13, "name": "King - Bergnaum" }, { "id": 14, "name": "Grant, Cole and Waelchi" }, { "id": 15, "name": "Tillman, Fritsch and Raynor" }, { "id": 17, "name": "Morissette - Grimes" } ] }, { "id": 113, "partners": [ { "id": 7, "name": "Schaden and Sons" }, { "id": 16, "name": "Medhurst Group" }, { "id": 18, "name": "Huels - Lemke" } ] } ] } ] } } } ```I feel like I'm missing something obvious here...
How to reproduce
include
.Expected behavior
To get all data, including deeply nested fields.
Prisma information
Environment & setup
Prisma Version