fix: data not returning from api-journeys to journeys modern#8944
fix: data not returning from api-journeys to journeys modern#8944
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdds a GraphQL field resolver Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
View your CI Pipeline Execution ↗ for commit ee4ddae
☁️ Nx Cloud last updated this comment at |
…tomisable-text-resets-after-editing-the
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apis/api-journeys/src/app/modules/journey/journey.resolver.ts`:
- Around line 1276-1287: The resolver journeyCustomizationDescription currently
always re-fetches the Journey without filtering out soft-deleted rows and causes
unnecessary DB calls; update JourneyResolver.journeyCustomizationDescription to
first check if the parent Journey object already has
journeyCustomizationDescription (e.g., if
journey.journeyCustomizationDescription !== undefined) and return it
immediately, and only call this.prismaService.journey.findUnique when missing,
adding a soft-delete filter in the query (where: { id: journey.id, deletedAt:
null }) and selecting journeyCustomizationDescription; this avoids N+1 queries
and excludes soft-deleted journeys.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 7ac8d504-cf80-46d1-af58-e309fcc731db
📒 Files selected for processing (1)
apis/api-journeys/src/app/modules/journey/journey.resolver.ts
| @ResolveField('journeyCustomizationDescription') | ||
| async journeyCustomizationDescription( | ||
| @Parent() journey: Journey | ||
| ): Promise<string | null> { | ||
| const journeyWithCustomizationDescription = | ||
| await this.prismaService.journey.findUnique({ | ||
| where: { id: journey.id }, | ||
| select: { journeyCustomizationDescription: true } | ||
| }) | ||
|
|
||
| return journeyWithCustomizationDescription?.journeyCustomizationDescription ?? null | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "1) Inspect resolver implementation around journeyCustomizationDescription:"
rg -n -C4 "journeyCustomizationDescription|findUnique|findFirst|deletedAt" apis/api-journeys/src/app/modules/journey/journey.resolver.ts
echo
echo "2) Confirm Journey model includes deletedAt (schema source of truth):"
fd -i "schema.prisma" apis | xargs -r rg -n -C3 "model Journey|deletedAt"Repository: JesusFilm/core
Length of output: 9514
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== 1) Check Journey type/interface to see what fields are available on `@Parent`() ==="
rg -n "interface Journey|type Journey" apis/api-journeys/src --max-count=20
echo
echo "=== 2) Compare nearby resolvers (journeyTheme, chatButton) to journeyCustomizationDescription ==="
sed -n '1260,1287p' apis/api-journeys/src/app/modules/journey/journey.resolver.ts
echo
echo "=== 3) Check if Prisma Journey model includes journeyCustomizationDescription as a direct field ==="
fd -i "schema.prisma" apis | xargs -r grep -n -A30 "model Journey"Repository: JesusFilm/core
Length of output: 6148
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== 1) Check full Prisma Journey model definition ==="
fd -i "schema.prisma" apis | head -1 | xargs grep -A100 "model Journey" | head -60
echo
echo "=== 2) Check if there are other resolvers that access parent fields directly (like journeyCustomizationDescription) ==="
rg -n "@ResolveField|@Parent" apis/api-journeys/src/app/modules/journey/journey.resolver.ts | head -20
echo
echo "=== 3) Look at queries/mutations to understand what fields are typically selected on Journey ==="
rg -n "select:|include:" apis/api-journeys/src/app/modules/journey/journey.resolver.ts | head -15Repository: JesusFilm/core
Length of output: 113
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== 1) Find schema.prisma file ==="
find apis -name "schema.prisma" -o -name "*.prisma"
echo
echo "=== 2) Once found, check Journey model ==="
find apis -name "*.prisma" | xargs cat 2>/dev/null | grep -A50 "^model Journey"
echo
echo "=== 3) Check if journeyCustomizationDescription appears in parent Journey selections ==="
rg -n "journeyCustomizationDescription" apis/api-journeys/src/app/modules/journey/ --max-count=20Repository: JesusFilm/core
Length of output: 136
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== 1) Check Journey GraphQL type definition ==="
rg -n -A30 "^type Journey" apis/api-journeys/src/app/modules/journey/journey.graphql
echo
echo "=== 2) Check if journeyCustomizationDescription is a direct field on Journey ==="
rg -n "journeyCustomizationDescription" apis/api-journeys/src/app/modules/journey/journey.graphql
echo
echo "=== 3) Check the journeyCustomizationField module which extends Journey ==="
rg -n -A10 "extend type Journey" apis/api-journeys/src/app/modules/journeyCustomizationField/journeyCustomizationField.graphqlRepository: JesusFilm/core
Length of output: 995
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== 1) Check what journeyCustomizationField extends Journey with ==="
cat apis/api-journeys/src/app/modules/journeyCustomizationField/journeyCustomizationField.graphql
echo
echo "=== 2) Check other extend type Journey declarations ==="
rg -n -B2 "extend type Journey" apis/api-journeys/src/app/modules/
echo
echo "=== 3) Check how journeyCustomizationDescription resolver is used in queries/how it's typically selected ==="
rg -n "journeyCustomizationDescription" apis/api-journeys/src/ -A2 -B2 | head -40Repository: JesusFilm/core
Length of output: 6806
Add soft-delete filter and avoid redundant fetches.
This resolver re-fetches the Journey entity without a deletedAt: null filter, violating the coding guideline. Additionally, it unconditionally hits the database even if the field may already be available on the parent Journey object, creating N+1 behavior on list queries.
Proposed change
`@ResolveField`('journeyCustomizationDescription')
async journeyCustomizationDescription(
`@Parent`() journey: Journey
): Promise<string | null> {
+ if (journey.journeyCustomizationDescription != null) {
+ return journey.journeyCustomizationDescription
+ }
+
const journeyWithCustomizationDescription =
- await this.prismaService.journey.findUnique({
- where: { id: journey.id },
+ await this.prismaService.journey.findFirst({
+ where: { id: journey.id, deletedAt: null },
select: { journeyCustomizationDescription: true }
})
- return journeyWithCustomizationDescription?.journeyCustomizationDescription ?? null
+ return (
+ journeyWithCustomizationDescription?.journeyCustomizationDescription ?? null
+ )
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@apis/api-journeys/src/app/modules/journey/journey.resolver.ts` around lines
1276 - 1287, The resolver journeyCustomizationDescription currently always
re-fetches the Journey without filtering out soft-deleted rows and causes
unnecessary DB calls; update JourneyResolver.journeyCustomizationDescription to
first check if the parent Journey object already has
journeyCustomizationDescription (e.g., if
journey.journeyCustomizationDescription !== undefined) and return it
immediately, and only call this.prismaService.journey.findUnique when missing,
adding a soft-delete filter in the query (where: { id: journey.id, deletedAt:
null }) and selecting journeyCustomizationDescription; this avoids N+1 queries
and excludes soft-deleted journeys.
Summary by CodeRabbit