chore: radioquestionblockcreate modern#8984
Conversation
…api-journeys-override-skill
…odify existing iconBlockCreate mutation for modern API
…tions for iconBlock mutations
…ization patterns in API journeys
…ck mutation in API gateway
…d override for API journeys
…I gateway schema for consistency
…ensure consistency across schemas
|
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)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe PR migrates the Changes
Sequence DiagramsequenceDiagram
participant Client
participant GraphQL as GraphQL Resolver
participant Auth as Authorization
participant Validation as Block Validation
participant Prisma as Prisma Transaction
participant Journey as Journey Service
Client->>GraphQL: radioQuestionBlockCreate(input)
GraphQL->>Auth: authorizeBlockCreate(journeyId, user)
Auth-->>GraphQL: authorized
GraphQL->>Validation: validateParentBlock(parentBlockId)
Validation-->>GraphQL: valid
GraphQL->>Prisma: $transaction {create block}
Prisma->>Prisma: compute parentOrder from sibling count
Prisma->>Prisma: create block record with connections
Prisma-->>GraphQL: block created
GraphQL->>Journey: setJourneyUpdatedAt(block)
Journey-->>GraphQL: journey updated
GraphQL-->>Client: RadioQuestionBlock!
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 52abc15
☁️ Nx Cloud last updated this comment at |
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
|
The latest updates on your projects.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
apis/api-journeys-modern/src/schema/block/image/transformInput.ts (1)
31-31: Consider adding a timeout for the external fetch.The
fetch(input.src)call has no timeout, which could cause the resolver to hang indefinitely if the remote server is slow or unresponsive. This may impact request latency and resource utilization under load.Example using AbortSignal timeout
- const response = await fetch(input.src) + const response = await fetch(input.src, { + signal: AbortSignal.timeout(10000) // 10 second timeout + })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apis/api-journeys-modern/src/schema/block/image/transformInput.ts` at line 31, The fetch call "const response = await fetch(input.src)" lacks a timeout; wrap the fetch with an AbortController (or use AbortSignal.timeout) and pass its signal to fetch so requests are aborted after a configurable timeout (e.g., 5s); ensure you clear any timer and handle abort/timeout errors (catch AbortError and return/throw a sane error), updating the code in transformInput.ts where input.src and response are used so the resolver doesn't hang on slow/unresponsive remote servers.
🤖 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-modern/src/schema/block/image/imageBlockCreate.mutation.ts`:
- Around line 7-12: The resolver currently uses input.parentBlockId as a
relation target without verifying it belongs to the same journey; call
validateParentBlock(input.parentBlockId, input.journeyId) before any use (and
before starting the transaction) to ensure the parent block is valid for this
journey, then proceed with authorizeBlockCreate and the existing create logic
(including any isCover replacement logic) inside the transaction; follow the
established pattern used across other block mutations by invoking
validateParentBlock outside the transaction so a foreign parentBlockId cannot be
connected or used to replace another journey’s cover.
- Around line 31-80: This mutation may change Journey.customizable but only
calls setJourneyUpdatedAt(tx, block); after the tx.block.create and
setJourneyUpdatedAt call (and before returning block), invoke the journey
customizability recalculation helper (e.g., recalculateJourneyCustomizability or
the existing recompute function) passing the transaction and the affected
journey id (use block.journeyId or input.journeyId) so the journey-level
customizable flag is recomputed after create/cover-replacement; ensure this runs
inside the same transaction (tx) and after
removeBlockAndChildren/getSiblingsInternal logic.
In `@apis/api-journeys-modern/src/schema/block/image/transformInput.ts`:
- Around line 44-50: The catch block in transformInput swallows non-Error throws
and returns a default transformedInput, which masks failures; update the catch
in transformInput to re-throw unknown exceptions (i.e., when ex is not an
instance of Error) instead of silently returning, and for Error instances
continue to throw a GraphQLError with ex.message and extensions: { code:
'BAD_USER_INPUT' } so that unexpected thrown values are propagated rather than
swallowed.
---
Nitpick comments:
In `@apis/api-journeys-modern/src/schema/block/image/transformInput.ts`:
- Line 31: The fetch call "const response = await fetch(input.src)" lacks a
timeout; wrap the fetch with an AbortController (or use AbortSignal.timeout) and
pass its signal to fetch so requests are aborted after a configurable timeout
(e.g., 5s); ensure you clear any timer and handle abort/timeout errors (catch
AbortError and return/throw a sane error), updating the code in
transformInput.ts where input.src and response are used so the resolver doesn't
hang on slow/unresponsive remote servers.
🪄 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: d4356f5c-c0bf-4769-8e89-58156f474bd9
📒 Files selected for processing (20)
.cursor/skills/create-api-journeys-override/SKILL.mdapis/api-gateway/schema.graphqlapis/api-journeys-modern/schema.graphqlapis/api-journeys-modern/src/schema/block/icon/iconBlockUpdate.mutation.spec.tsapis/api-journeys-modern/src/schema/block/icon/iconBlockUpdate.mutation.tsapis/api-journeys-modern/src/schema/block/icon/index.tsapis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.spec.tsapis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.tsapis/api-journeys-modern/src/schema/block/image/imageBlockUpdate.mutation.spec.tsapis/api-journeys-modern/src/schema/block/image/imageBlockUpdate.mutation.tsapis/api-journeys-modern/src/schema/block/image/index.tsapis/api-journeys-modern/src/schema/block/image/transformInput.tsapis/api-journeys-modern/src/schema/block/radioOption/index.tsapis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockCreate.mutation.spec.tsapis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockCreate.mutation.tsapis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockUpdate.mutation.spec.tsapis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockUpdate.mutation.tsapis/api-journeys-modern/src/schema/block/radioQuestion/index.tsapis/api-journeys-modern/src/schema/block/radioQuestion/radioQuestionBlockCreate.mutation.spec.tsapis/api-journeys-modern/src/schema/block/radioQuestion/radioQuestionBlockCreate.mutation.ts
…, documenting steps for Prisma and GraphQL modifications
|
I see you added the "on stage" label, I'll get this merged to the stage branch! |
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Summary by CodeRabbit
New Features
Tests