Skip to content

chore: spacerblockcreate modern#8989

Merged
mikeallisonJS merged 20 commits intomainfrom
26-00-MA-chore-spacerblockcreate-modern
Apr 13, 2026
Merged

chore: spacerblockcreate modern#8989
mikeallisonJS merged 20 commits intomainfrom
26-00-MA-chore-spacerblockcreate-modern

Conversation

@mikeallisonJS
Copy link
Copy Markdown
Collaborator

@mikeallisonJS mikeallisonJS commented Apr 8, 2026

Summary by CodeRabbit

  • New Features

    • Expanded block creation and update operations now supported through the modernized API service, including icon, image, radio option, radio question, sign-up, and spacer blocks. Enhanced block handling ensures consistent behavior and improved compatibility.
  • Tests

    • Added comprehensive test coverage for new block operations to ensure reliability and quality.

mikeallisonJS and others added 16 commits March 20, 2026 22:39
…odify existing iconBlockCreate mutation for modern API
@mikeallisonJS mikeallisonJS requested a review from csiyang April 8, 2026 21:00
@mikeallisonJS mikeallisonJS self-assigned this Apr 8, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 8, 2026

Warning

Rate limit exceeded

@mikeallisonJS has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 0 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 55 minutes and 0 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e2c0cf36-0440-4b76-a714-10fcd4b4a26f

📥 Commits

Reviewing files that changed from the base of the PR and between 3aaa91c and db83559.

📒 Files selected for processing (1)
  • apis/api-gateway/schema.graphql

Walkthrough

This PR implements Apollo Federation override mutations in api-journeys-modern, routing block creation and update operations from the legacy api-journeys service. It adds GraphQL mutations for icon, image, radioOption, radioQuestion, signUp, and spacer blocks, complete with authorization, validation, and database persistence logic. The API gateway schema is updated to direct these mutations to the modern service with override directives. Comprehensive test suites and a skill documentation guide accompany the implementation.

Changes

Cohort / File(s) Summary
Documentation & Gateway Routing
.cursor/skills/create-api-journeys-override/SKILL.md, apis/api-gateway/schema.graphql
Added skill documentation outlining the override resolver creation process; updated gateway schema to route 7 block mutations (create: icon, image, radioOption, radioQuestion, signUp, spacer; update: radioQuestion) from API_JOURNEYS to API_JOURNEYS_MODERN with @join__field(override: "api-journeys").
Schema Definitions
apis/api-journeys-modern/schema.graphql
Declared 10 new Mutation fields with @override(from: "api-journeys") directives: iconBlockUpdate, imageBlockCreate, imageBlockUpdate, radioOptionBlockCreate, radioOptionBlockUpdate, radioQuestionBlockCreate, radioQuestionBlockUpdate, signUpBlockCreate, signUpBlockUpdate, spacerBlockCreate.
Icon Block Override
apis/api-journeys-modern/src/schema/block/icon/iconBlockUpdate.mutation.ts, .../iconBlockUpdate.mutation.spec.ts, .../index.ts
Implemented iconBlockUpdate mutation with authorization and update persistence; includes tests for authorized/unauthorized paths and partial input scenarios.
Image Block Overrides
apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.ts, .../imageBlockCreate.mutation.spec.ts, .../imageBlockUpdate.mutation.ts, .../imageBlockUpdate.mutation.spec.ts, .../transformInput.ts, .../index.ts
Implemented imageBlockCreate (with cover-image special handling) and imageBlockUpdate mutations; added transformInput utility for extracting image dimensions and computing BlurHash; comprehensive test coverage for authorization, cover-image cleanup, and optional field handling.
RadioOption Block Overrides
apis/api-journeys-modern/src/schema/block/radioOption/radioOptionBlockCreate.mutation.ts, .../radioOptionBlockCreate.mutation.spec.ts, .../radioOptionBlockUpdate.mutation.ts, .../radioOptionBlockUpdate.mutation.spec.ts, .../index.ts
Implemented create and update mutations with parent block validation and parentOrder computation; includes tests for authorized/unauthorized paths and optional field scenarios.
RadioQuestion Block Overrides
apis/api-journeys-modern/src/schema/block/radioQuestion/radioQuestionBlockCreate.mutation.ts, .../radioQuestionBlockCreate.mutation.spec.ts, .../radioQuestionBlockUpdate.mutation.ts, .../radioQuestionBlockUpdate.mutation.spec.ts, .../index.ts
Implemented create and update mutations; update mutation handles parentBlockId and optional gridView parameters; tests validate transactional behavior and authorization enforcement.
SignUp Block Overrides
apis/api-journeys-modern/src/schema/block/signUp/signUpBlockCreate.mutation.ts, .../signUpBlockCreate.mutation.spec.ts, .../signUpBlockUpdate.mutation.ts, .../signUpBlockUpdate.mutation.spec.ts, .../index.ts
Implemented create and update mutations; update mutation validates submitIconId references when provided; tests cover authorization, icon validation, and field updates.
Spacer Block Override
apis/api-journeys-modern/src/schema/block/spacer/spacerBlockCreate.mutation.ts, .../spacerBlockCreate.mutation.spec.ts, .../index.ts
Implemented spacerBlockCreate mutation with standard authorization, parent validation, and transaction-wrapped persistence.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • JesusFilm/core#8915: Modifies GraphQL join/override routing for block mutations between api-journeys and api-journeys-modern services.

Suggested reviewers

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

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title "chore: spacerblockcreate modern" is misleading and significantly underrepresents the scope of changes. The changeset involves 10+ new block mutation implementations (icon, image, radio option, radio question, sign-up, spacer) with comprehensive tests, schema updates across multiple GraphQL files, and support tooling—not just spacer block creation. Revise the title to accurately reflect the full scope, e.g., "chore: add modern block mutation overrides (spacer, sign-up, radio, image, icon)" or "chore: implement Apollo Federation overrides for block mutations in api-journeys-modern".
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.
✅ 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-spacerblockcreate-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.

@mikeallisonJS mikeallisonJS changed the title 26 00 ma chore spacerblockcreate modern chore: spacerblockcreate modern Apr 8, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 8, 2026

View your CI Pipeline Execution ↗ for commit db83559

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

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

@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin April 8, 2026 21:02 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - short-links April 8, 2026 21:02 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys April 8, 2026 21:02 Inactive
@github-actions github-actions Bot requested a deployment to Preview - resources April 8, 2026 21:02 Pending
@github-actions github-actions Bot temporarily deployed to Preview - watch April 8, 2026 21:02 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - player April 8, 2026 21:02 Inactive
@github-actions github-actions Bot requested a deployment to Preview - videos-admin April 8, 2026 21:02 Pending
@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 Tue Apr 14 11:04:08 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 Tue Apr 14 11:04:10 NZST 2026

@github-actions github-actions Bot temporarily deployed to Preview - journeys April 8, 2026 21:07 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - resources April 8, 2026 21:07 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)
videos-admin ✅ Ready videos-admin preview Tue Apr 14 11:04:33 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 Tue Apr 14 11:04:38 NZST 2026

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: 7

🧹 Nitpick comments (1)
apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.spec.ts (1)

151-213: Cover the invalid-cover branches too.

This suite exercises the successful cover replacement path, but it never asserts the two explicit guardrails in the resolver: isCover without parentBlockId, and parentBlockId pointing at a missing block. Those are the branches most likely to regress because they only show up on malformed input.

🤖 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/imageBlockCreate.mutation.spec.ts`
around lines 151 - 213, Add two unit tests in imageBlockCreate.mutation.spec.ts
to exercise the resolver's guard clauses: (1) call authClient with input {
isCover: true } but without parentBlockId and assert the mutation returns the
expected validation/error response for "isCover without parentBlockId"; (2) mock
tx.block.findUnique to return null for the given parentBlockId (simulating a
missing parent) and call authClient with that parentBlockId and isCover true,
asserting the resolver returns the expected error for "parentBlockId points at a
missing block". Use the same patterns as existing tests (authClient with
document IMAGE_BLOCK_CREATE, prismaMock.$transaction mocking tx, and assertions
on result/error shape) and reference tx.block.findUnique and the
imageBlockCreate mutation behavior so the new specs cover those invalid-cover
branches.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.cursor/skills/create-api-journeys-override/SKILL.md:
- Around line 316-319: Update the documented test command for the
api-journeys-modern target so it runs sequentially: change the example "nx test
api-journeys-modern --testPathPattern=\"<fieldName>\"" to include the Jest
runInBand flag (i.e., add --runInBand) so the invocation becomes "nx test
api-journeys-modern --runInBand --testPathPattern=\"<fieldName>\""; ensure any
other examples in the same section that invoke nx test api-journeys-modern also
include --runInBand to enforce non-parallel execution as required by the
apis/api-journeys-modern spec.

In
`@apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.ts`:
- Around line 53-80: The mutation writes the block's customizable flag but never
recalculates Journey.customizable, leaving the journey stale; after awaiting
tx.block.create(...) and setJourneyUpdatedAt(tx, block), call the existing
recalculation function (e.g., recalculateJourneyCustomizability or whatever
project convention you have) with the transaction and input.journeyId to update
Journey.customizable immediately (i.e., invoke
recalculateJourneyCustomizability(tx, input.journeyId) right after
setJourneyUpdatedAt).
- Around line 26-29: Move the authorization call before any processing of
untrusted input: in the resolve function call authorizeBlockCreate using
args.input.journeyId and context.user before invoking transformInput so we don't
run transformInput on attacker-controlled src; specifically, replace the current
order in the resolve method so authorizeBlockCreate(args.input.journeyId,
context.user) runs first, then call transformInput({ ...args.input }) and
continue with the rest of the logic.

In `@apis/api-journeys-modern/src/schema/block/image/transformInput.ts`:
- Around line 44-50: The catch block in transformInput (catch (ex) { ... })
swallows non-Error exceptions causing transformedInput to be returned with empty
values; change the handler to surface unknown throws by either rethrowing the
original exception or converting it to a GraphQLError (e.g., stringify ex) and
include it in processLogger/error output so callers see the failure instead of
silently receiving an empty transformedInput; ensure all branches throw or log
and do not fall through to returning transformedInput on unexpected exception
types.

In
`@apis/api-journeys-modern/src/schema/block/radioQuestion/radioQuestionBlockUpdate.mutation.ts`:
- Around line 1-19: The resolver must validate the target block’s type and the
new parent before calling the generic update: after authorizeBlockUpdate(id,
context.user) but before calling update(id, {...}), fetch and assert the
existing block is a RadioQuestionBlock (e.g. check its typename or use
RadioQuestionBlock.isTypeOf logic) and call validateParentBlock(parentBlockId)
(outside any prisma.$transaction) to ensure the parent exists/belongs to the
same journey; only if both checks pass proceed to update(id, { parentBlockId,
gridView }).

In
`@apis/api-journeys-modern/src/schema/block/signUp/signUpBlockUpdate.mutation.spec.ts`:
- Around line 187-230: The tests for invalid submitIconId and submitIconId not
child of block are missing assertions/mocks for the authorization path, so
update the two it(...) cases to also mock fetchBlockWithJourneyAcl (or the
helper used to fetch the block with ACL) and assert ability is called or that
fetchBlockWithJourneyAcl is invoked, ensuring the authorization path is
exercised; specifically, in signUpBlockUpdate.mutation.spec.ts augment the
setups around SIGN_UP_BLOCK_UPDATE (and the prismaMock.block.findUnique mocks)
to stub/spy fetchBlockWithJourneyAcl (or the ability check) to return the
expected block/ability and add expectations that fetchBlockWithJourneyAcl (or
ability) was called, so the tests fail if auth is not enforced.

In
`@apis/api-journeys-modern/src/schema/block/signUp/signUpBlockUpdate.mutation.ts`:
- Around line 25-40: Before calling authorizeBlockUpdate or update, load the
target block (using prisma.block.findUnique for id) and assert it exists and has
type 'SignUpBlock'; if not, throw a GraphQLError. Do the same when validating
input.submitIconId: fetch the submitIcon via prisma.block.findUnique, ensure
submitIcon.parentBlockId === id AND submitIcon.type is the expected icon block
type (e.g., 'IconBlock'), otherwise throw NOT_FOUND/invalid error. Only after
these type checks pass call authorizeBlockUpdate(id, context.user) and then
update(id, { ...input }).

---

Nitpick comments:
In
`@apis/api-journeys-modern/src/schema/block/image/imageBlockCreate.mutation.spec.ts`:
- Around line 151-213: Add two unit tests in imageBlockCreate.mutation.spec.ts
to exercise the resolver's guard clauses: (1) call authClient with input {
isCover: true } but without parentBlockId and assert the mutation returns the
expected validation/error response for "isCover without parentBlockId"; (2) mock
tx.block.findUnique to return null for the given parentBlockId (simulating a
missing parent) and call authClient with that parentBlockId and isCover true,
asserting the resolver returns the expected error for "parentBlockId points at a
missing block". Use the same patterns as existing tests (authClient with
document IMAGE_BLOCK_CREATE, prismaMock.$transaction mocking tx, and assertions
on result/error shape) and reference tx.block.findUnique and the
imageBlockCreate mutation behavior so the new specs cover those invalid-cover
branches.
🪄 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: 0ec6bbb9-3c6f-46ba-bab3-e318948bbb22

📥 Commits

Reviewing files that changed from the base of the PR and between 2d4a0dd and 3aaa91c.

📒 Files selected for processing (30)
  • .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
  • apis/api-journeys-modern/src/schema/block/radioQuestion/radioQuestionBlockUpdate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/radioQuestion/radioQuestionBlockUpdate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/signUp/index.ts
  • apis/api-journeys-modern/src/schema/block/signUp/signUpBlockCreate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/signUp/signUpBlockCreate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/signUp/signUpBlockUpdate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/signUp/signUpBlockUpdate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/spacer/index.ts
  • apis/api-journeys-modern/src/schema/block/spacer/spacerBlockCreate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/spacer/spacerBlockCreate.mutation.ts

Comment thread .cursor/skills/create-api-journeys-override/SKILL.md
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
@github-actions github-actions Bot temporarily deployed to Preview - resources April 10, 2026 18:58 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys April 10, 2026 18:58 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - short-links April 10, 2026 18:58 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - watch April 10, 2026 18:58 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin April 10, 2026 18:58 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - videos-admin April 10, 2026 18:58 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - player April 10, 2026 18:58 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - short-links April 13, 2026 23:02 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys April 13, 2026 23:02 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - watch April 13, 2026 23:02 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - videos-admin April 13, 2026 23:02 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - player April 13, 2026 23:02 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - resources April 13, 2026 23:02 Inactive
@github-actions github-actions Bot temporarily deployed to Preview - journeys-admin April 13, 2026 23:02 Inactive
@mikeallisonJS mikeallisonJS enabled auto-merge April 13, 2026 23:10
@mikeallisonJS mikeallisonJS added this pull request to the merge queue Apr 13, 2026
Merged via the queue into main with commit 83139dc Apr 13, 2026
38 checks passed
@mikeallisonJS mikeallisonJS deleted the 26-00-MA-chore-spacerblockcreate-modern branch April 13, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants