Skip to content

Commit

Permalink
Fixed a bug where totalCount was not selected correctly when selected…
Browse files Browse the repository at this point in the history
… through a fragment
  • Loading branch information
hayes committed May 16, 2023
1 parent 9d968a6 commit e8139e7
Show file tree
Hide file tree
Showing 3 changed files with 226 additions and 94 deletions.
5 changes: 5 additions & 0 deletions .changeset/lemon-oranges-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@pothos/plugin-prisma': patch
---

Fixed a bug where totalCount was not selected correctly when selected through a fragment
9 changes: 6 additions & 3 deletions packages/plugin-prisma/src/util/map-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,12 @@ function resolveIndirectInclude(
}
continue;
case Kind.FRAGMENT_SPREAD:
if (info.fragments[sel.name.value].typeCondition.name.value === include.type) {
if (
!include.type ||
info.fragments[sel.name.value].typeCondition.name.value === include.type
) {
resolveIndirectInclude(
info.schema.getType(include.type)!,
include.type ? info.schema.getType(include.type)! : type,
info,
info.fragments[sel.name.value],
includePath,
Expand All @@ -148,7 +151,7 @@ function resolveIndirectInclude(
continue;

case Kind.INLINE_FRAGMENT:
if (!sel.typeCondition || sel.typeCondition.name.value === include.type) {
if (!sel.typeCondition || !include.type || sel.typeCondition.name.value === include.type) {
resolveIndirectInclude(
sel.typeCondition ? info.schema.getType(sel.typeCondition.name.value)! : type,
info,
Expand Down

1 comment on commit e8139e7

@vercel
Copy link

@vercel vercel bot commented on e8139e7 May 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.