Skip to content

chore: radioquestionblockcreate modern#8984

Merged
mikeallisonJS merged 13 commits intomainfrom
26-00-MA-chore-radioquestionblockcreate-modern
Apr 10, 2026
Merged

chore: radioquestionblockcreate modern#8984
mikeallisonJS merged 13 commits intomainfrom
26-00-MA-chore-radioquestionblockcreate-modern

Conversation

@mikeallisonJS
Copy link
Copy Markdown
Collaborator

@mikeallisonJS mikeallisonJS commented Apr 8, 2026

Summary by CodeRabbit

  • New Features

    • New API mutations for creating radio question blocks and managing radio options
    • Enhanced update operations for icon and image blocks
  • Tests

    • Added comprehensive test coverage for radio question block creation

@mikeallisonJS mikeallisonJS requested a review from csiyang April 8, 2026 20:11
@mikeallisonJS mikeallisonJS self-assigned this Apr 8, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d9c0a7c4-b11f-4470-bf84-26f924eabf00

📥 Commits

Reviewing files that changed from the base of the PR and between 0ff810b and 52abc15.

📒 Files selected for processing (1)
  • apis/api-gateway/schema.graphql
🚧 Files skipped from review as they are similar to previous changes (1)
  • apis/api-gateway/schema.graphql

Walkthrough

The PR migrates the radioQuestionBlockCreate mutation from the legacy api-journeys graph to the modern api-journeys-modern graph in a federated GraphQL schema. The mutation resolver is implemented with authorization checks, parent block validation, and a database transaction that creates the block and updates the journey timestamp.

Changes

Cohort / File(s) Summary
Schema Definitions
apis/api-gateway/schema.graphql, apis/api-journeys-modern/schema.graphql
Updated gateway schema to redirect radioQuestionBlockCreate mutation to the modern graph. Added five new mutations to modern schema: radioQuestionBlockCreate, radioOptionBlockCreate, radioOptionBlockUpdate, iconBlockUpdate, imageBlockUpdate—all with @override directive.
Mutation Implementation
apis/api-journeys-modern/src/schema/block/radioQuestion/radioQuestionBlockCreate.mutation.ts
Implemented resolver for radioQuestionBlockCreate mutation. Enforces authorization via authorizeBlockCreate, validates parent block via validateParentBlock, executes Prisma transaction to create block record with computed parentOrder based on sibling count, and updates journey timestamp.
Module Integration
apis/api-journeys-modern/src/schema/block/radioQuestion/index.ts
Added import for new mutation module to register the resolver as a side effect.
Test Coverage
apis/api-journeys-modern/src/schema/block/radioQuestion/radioQuestionBlockCreate.mutation.spec.ts
Added comprehensive test suite covering successful block creation with authorization, forbidden response on auth failure, and creation with custom ID. Mocks authorization checks, journey ACL fetching, and Prisma transaction operations.

Sequence Diagram

sequenceDiagram
    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!
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • csiyang
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'chore: radioquestionblockcreate modern' is vague and uses abbreviated/unclear terminology without context about what the change accomplishes. Consider a more descriptive title that clarifies the actual change, such as 'chore: add radioQuestionBlockCreate mutation to API journeys modern schema' or similar.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 26-00-MA-chore-radioquestionblockcreate-modern

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 8, 2026

View your CI Pipeline Execution ↗ for commit 52abc15

Command Status Duration Result
nx run journeys-admin-e2e:e2e ✅ Succeeded 26s View ↗
nx run journeys-e2e:e2e ✅ Succeeded 20s View ↗
nx run resources-e2e:e2e ✅ Succeeded 16s View ↗
nx run videos-admin-e2e:e2e ✅ Succeeded 4s View ↗
nx run watch-e2e:e2e ✅ Succeeded 18s View ↗
nx run short-links-e2e:e2e ✅ Succeeded 3s View ↗
nx run player-e2e:e2e ✅ Succeeded 4s View ↗
nx run-many --target=vercel-alias --projects=jo... ✅ Succeeded 2s View ↗
Additional runs (20) ✅ Succeeded ... View ↗

☁️ Nx Cloud last updated this comment at 2026-04-09 23:45:35 UTC

@github-actions github-actions Bot temporarily deployed to Preview - journeys April 8, 2026 20:13 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - watch April 8, 2026 20:13 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - short-links April 8, 2026 20:13 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - player April 8, 2026 20:13 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin April 8, 2026 20:13 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - resources April 8, 2026 20:13 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - videos-admin April 8, 2026 20:13 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
short-links ✅ Ready short-links preview Fri Apr 10 11:41:39 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys ✅ Ready journeys preview Fri Apr 10 11:42:09 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
resources ✅ Ready resources preview Fri Apr 10 11:42:07 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
videos-admin ✅ Ready videos-admin preview Fri Apr 10 11:42:01 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
player ✅ Ready player preview Fri Apr 10 11:41:35 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
watch ✅ Ready watch preview Fri Apr 10 11:41:48 NZST 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 8, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys-admin ✅ Ready journeys-admin preview Fri Apr 10 11:42:01 NZST 2026

@github-actions github-actions Bot temporarily deployed to Preview - short-links April 8, 2026 20:17 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - watch April 8, 2026 20:17 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin April 8, 2026 20:17 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - player April 8, 2026 20:17 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys April 8, 2026 20:17 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - videos-admin April 8, 2026 20:17 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - resources April 8, 2026 20:17 Inactive
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d4a0dd and 0ff810b.

📒 Files selected for processing (20)
  • .cursor/skills/create-api-journeys-override/SKILL.md
  • apis/api-gateway/schema.graphql
  • apis/api-journeys-modern/schema.graphql
  • apis/api-journeys-modern/src/schema/block/icon/iconBlockUpdate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/icon/iconBlockUpdate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/icon/index.ts
  • apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/image/imageBlockUpdate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/image/imageBlockUpdate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/image/index.ts
  • apis/api-journeys-modern/src/schema/block/image/transformInput.ts
  • apis/api-journeys-modern/src/schema/block/radioOption/index.ts
  • apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockCreate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockCreate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockUpdate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockUpdate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/radioQuestion/index.ts
  • apis/api-journeys-modern/src/schema/block/radioQuestion/radioQuestionBlockCreate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/radioQuestion/radioQuestionBlockCreate.mutation.ts

Comment thread apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.ts Outdated
Comment thread apis/api-journeys-modern/src/schema/block/image/transformInput.ts
…, documenting steps for Prisma and GraphQL modifications
@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin April 9, 2026 23:39 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - player April 9, 2026 23:39 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - resources April 9, 2026 23:39 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - watch April 9, 2026 23:39 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - short-links April 9, 2026 23:39 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - videos-admin April 9, 2026 23:39 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys April 9, 2026 23:39 Inactive
@stage-branch-merger
Copy link
Copy Markdown
Contributor

I see you added the "on stage" label, I'll get this merged to the stage branch!

@mikeallisonJS mikeallisonJS enabled auto-merge April 10, 2026 01:14
@mikeallisonJS mikeallisonJS added this pull request to the merge queue Apr 10, 2026
Merged via the queue into main with commit 78eecb8 Apr 10, 2026
40 checks passed
@mikeallisonJS mikeallisonJS deleted the 26-00-MA-chore-radioquestionblockcreate-modern branch April 10, 2026 01:25
tanflem pushed a commit that referenced this pull request Apr 13, 2026
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants