Skip to content

feat: update iconBlockCreate mutation to use modern API and import ne…#8883

Open
mikeallisonJS wants to merge 20 commits intomainfrom
26-00-MA-refactor-iconblockcreate-modern
Open

feat: update iconBlockCreate mutation to use modern API and import ne…#8883
mikeallisonJS wants to merge 20 commits intomainfrom
26-00-MA-refactor-iconblockcreate-modern

Conversation

@mikeallisonJS
Copy link
Collaborator

@mikeallisonJS mikeallisonJS commented Mar 19, 2026

…w mutation file

Summary by CodeRabbit

  • New Features
    • Icon blocks can now be created in journeys.
    • Card blocks can now be updated in journeys.

mikeallisonJS and others added 6 commits March 13, 2026 23:23
- Moved `buttonBlockUpdate` mutation to the modern API schema and adjusted its input type.
- Updated `cardBlockCreate` mutation to use the modern API.
- Removed deprecated `journeyId` parameter from `buttonBlockUpdate` in the legacy schema.
- Cleaned up related resolver and input files for consistency and clarity.
…for modern API

- Removed the `cardBlockCreate` mutation from the legacy API and adjusted related resolver tests.
- Updated the `cardBlockUpdate` mutation to include the `journeyId` parameter in the modern API schema.
- Cleaned up input types and resolver files for consistency across APIs.
- Eliminated the `CardBlockCreateInput` type from the resolver and related test files.
- Streamlined the `card.resolver.ts` and `card.resolver.spec.ts` for improved clarity and consistency.
- Changed the `cardBlockUpdate` mutation in both legacy and modern API schemas to make the return type non-nullable.
- Updated the `journeyId` parameter in the `cardBlockUpdate` mutation to be non-nullable in the modern API schema.
- Ensured consistency across API schemas by aligning mutation definitions.
@mikeallisonJS mikeallisonJS requested a review from csiyang March 19, 2026 21:31
@mikeallisonJS mikeallisonJS self-assigned this Mar 19, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 19, 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: 03a9489b-88e6-4670-af32-8f535cace703

📥 Commits

Reviewing files that changed from the base of the PR and between 85b5ac4 and 87d3a8e.

📒 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 pull request updates the GraphQL federation routing of the iconBlockCreate mutation to the API_JOURNEYS_MODERN subgraph, adds corresponding schema declarations and implementations for icon block creation and card block update mutations, including authorization checks, parent block validation, Prisma transaction handling, and comprehensive test coverage.

Changes

Cohort / File(s) Summary
Federation Schema Routing
apis/api-gateway/schema.graphql
Updated iconBlockCreate mutation routing from API_JOURNEYS to API_JOURNEYS_MODERN with api-journeys override annotation, directing resolution to the modern journeys subgraph.
Modern Journeys Schema
apis/api-journeys-modern/schema.graphql
Added two new mutation declarations: cardBlockUpdate for updating existing card blocks and iconBlockCreate for creating new icon blocks, both with @override(from: "api-journeys") federation directives.
Icon Block Mutation Implementation
apis/api-journeys-modern/src/schema/block/icon/iconBlockCreate.mutation.ts, apis/api-journeys-modern/src/schema/block/icon/index.ts
Implemented the iconBlockCreate GraphQL mutation resolver with authentication enforcement, authorization validation, parent block existence verification, and Prisma transaction management for atomic block and journey creation/update operations.
Icon Block Mutation Tests
apis/api-journeys-modern/src/schema/block/icon/iconBlockCreate.mutation.spec.ts
Added comprehensive Jest test suite covering successful icon block creation with and without optional fields, authorization denial errors, and missing parent block resolution errors, with mocked Prisma transaction behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title describes the main change: updating iconBlockCreate mutation to use modern API and importing a new mutation file, which aligns with the core changes across the schema files and implementation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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-refactor-iconblockcreate-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

nx-cloud bot commented Mar 19, 2026

🤖 Nx Cloud AI Fix Eligible

An automatically generated fix could have helped fix failing tasks for this run, but Self-healing CI is disabled for this workspace. Visit workspace settings to enable it and get automatic fixes in future runs.

To disable these notifications, a workspace admin can disable them in workspace settings.


View your CI Pipeline Execution ↗ for commit 87d3a8e

Command Status Duration Result
nx run journeys-e2e:e2e ❌ Failed 3m 25s View ↗
nx run journeys-admin-e2e:e2e ✅ Succeeded 31s View ↗
nx run watch-e2e:e2e ✅ Succeeded 27s View ↗
nx run resources-e2e:e2e ✅ Succeeded 26s View ↗
nx run player-e2e:e2e ✅ Succeeded 3s View ↗
nx run videos-admin-e2e:e2e ✅ Succeeded 4s View ↗
nx run short-links-e2e:e2e ✅ Succeeded 3s 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-03-23 23:19:06 UTC

@nx-cloud
Copy link

nx-cloud bot commented Mar 19, 2026

View your CI Pipeline Execution ↗ for commit 8435fed

Command Status Duration Result
nx run-many --target=codegen --all --parallel=3 ✅ Succeeded 2s View ↗
nx run-many --target=prisma-generate --all --pa... ✅ Succeeded 4s View ↗

☁️ Nx Cloud last updated this comment at 2026-03-19 21:38:10 UTC

@github-actions github-actions bot requested a deployment to Preview - videos-admin March 19, 2026 21:33 Pending
@github-actions github-actions bot temporarily deployed to Preview - short-links March 19, 2026 21:33 Inactive
@github-actions github-actions bot requested a deployment to Preview - journeys March 19, 2026 21:33 Pending
@github-actions github-actions bot temporarily deployed to Preview - player March 19, 2026 21:33 Inactive
@github-actions github-actions bot requested a deployment to Preview - resources March 19, 2026 21:33 Pending
@github-actions github-actions bot requested a deployment to Preview - journeys-admin March 19, 2026 21:33 Pending
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
short-links ✅ Ready short-links preview Tue Mar 24 12:12:28 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
player ✅ Ready player preview Tue Mar 24 12:12:17 NZDT 2026

@github-actions github-actions bot temporarily deployed to Preview - short-links March 19, 2026 21:38 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 19, 2026 21:38 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys March 19, 2026 21:38 Inactive
@github-actions github-actions bot temporarily deployed to Preview - player March 19, 2026 21:38 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 19, 2026 21:38 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch March 19, 2026 21:38 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 19, 2026 21:38 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
videos-admin ✅ Ready videos-admin preview Tue Mar 24 12:12:33 NZDT 2026

@github-actions
Copy link
Contributor

github-actions bot commented Mar 19, 2026

The latest updates on your projects.

Name Status Preview Updated (UTC)
journeys ✅ Ready journeys preview Tue Mar 24 12:13:03 NZDT 2026

Copy link
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: 1

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

141-212: Add a failing parentBlockId case.

The new validateParentBlock() branch only has a happy-path assertion here. If that validation call is accidentally removed, this suite still stays green. Add a case where the parent is missing or from another journey and assert the mutation fails.

🧪 Suggested coverage
+  it('returns BAD_USER_INPUT when parentBlockId is outside the journey', async () => {
+    fetchBlockWithJourneyAcl.mockResolvedValue({
+      id,
+      journeyId: 'journeyId',
+      journey: { id: 'journeyId' }
+    })
+    mockAbility.mockReturnValue(true)
+    prismaMock.block.findFirst.mockResolvedValueOnce(null)
+
+    const result = await authClient({
+      document: CARD_BLOCK_UPDATE,
+      variables: { id, input: { parentBlockId: 'otherParentId' } }
+    })
+
+    expect(result).toEqual({
+      data: null,
+      errors: [
+        expect.objectContaining({
+          message: 'parent block not found in journey'
+        })
+      ]
+    })
+  })
🤖 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/card/cardBlockUpdate.mutation.spec.ts`
around lines 141 - 212, Add a negative test that asserts validateParentBlock()
actually blocks invalid parents: in cardBlockUpdate.mutation.spec.ts create a
new it() where fetchBlockWithJourneyAcl.mockResolvedValue(...) and
mockAbility.mockReturnValue(true) as before, then set
prismaMock.block.findFirst.mockResolvedValue(null) (or a block with a different
journeyId) to simulate a missing/wrong parent and call authClient({ document:
CARD_BLOCK_UPDATE, variables: { id, input: { parentBlockId: 'badParentId', ... }
} }); assert the mutation fails (expect an error response or that authClient
throws) and that tx.block.update is not called—this ensures
validateParentBlock() path is covered and will fail the test if removed.
🤖 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-gateway/schema.graphql`:
- Around line 354-362: The gateway schema still uses `@join__field`(... override:
"api-journeys") for the cardBlockCreate and cardBlockUpdate fields (symbols:
cardBlockCreate, cardBlockUpdate, `@join__field` override: "api-journeys"), but
the legacy service no longer exposes those mutations; remove the override
attribute from the `@join__field` directives on cardBlockCreate and
cardBlockUpdate so ownership is explicit (or alternatively restore the legacy
mutations in the legacy service if you need a fallback), ensuring the gateway no
longer references a non-existent override path.

---

Nitpick comments:
In
`@apis/api-journeys-modern/src/schema/block/card/cardBlockUpdate.mutation.spec.ts`:
- Around line 141-212: Add a negative test that asserts validateParentBlock()
actually blocks invalid parents: in cardBlockUpdate.mutation.spec.ts create a
new it() where fetchBlockWithJourneyAcl.mockResolvedValue(...) and
mockAbility.mockReturnValue(true) as before, then set
prismaMock.block.findFirst.mockResolvedValue(null) (or a block with a different
journeyId) to simulate a missing/wrong parent and call authClient({ document:
CARD_BLOCK_UPDATE, variables: { id, input: { parentBlockId: 'badParentId', ... }
} }); assert the mutation fails (expect an error response or that authClient
throws) and that tx.block.update is not called—this ensures
validateParentBlock() path is covered and will fail the test if removed.
🪄 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: ddd9f4a6-569c-4efb-bce2-9629fb7e3a55

📥 Commits

Reviewing files that changed from the base of the PR and between 845b55d and 85b5ac4.

⛔ Files ignored due to path filters (47)
  • apis/api-journeys/src/__generated__/graphql.ts is excluded by !**/__generated__/**
  • apis/api-journeys/src/app/__generated__/graphql.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/BlockActionDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/BlockDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/BlockDeleteForCoverImage.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/BlockOrderUpdate.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/CardCtaDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/CardFormDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/CardIntroDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/CardPollDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/CardQuoteDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/CardVideoDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/CardVideoRestore.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/CoverBlockDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/CoverBlockRestore.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/DuplicatedBlock.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/GetStepBlocksWithPosition.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/JourneyAiTranslateCreateSubscription.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/JourneyImageBlockDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/MenuBlockDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/MultiselectWithButtonDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/MultiselectWithButtonRestore.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/NewBlock.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/PosterImageBlockDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/PosterImageBlockRestore.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/RadioOptionImageDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/RadioOptionImageRestore.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/RestoredBlock.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/StepBlockCreateFromAction.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/StepBlockCreateFromSocialPreview.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/StepBlockDeleteFromAction.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/StepBlockDeleteFromActionWithoutAction.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/StepBlockDeleteFromSocialPreview.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/StepBlockDeleteFromStep.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/StepBlockRestoreFromAction.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/StepBlockRestoreFromSocialPreview.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/TestJourney.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/TextResponseWithButtonDelete.ts is excluded by !**/__generated__/**
  • apps/journeys-admin/__generated__/TranslatedJourney.ts is excluded by !**/__generated__/**
  • apps/journeys/__generated__/JourneyAiTranslateCreateSubscription.ts is excluded by !**/__generated__/**
  • apps/journeys/__generated__/TranslatedJourney.ts is excluded by !**/__generated__/**
  • apps/resources/__generated__/JourneyAiTranslateCreateSubscription.ts is excluded by !**/__generated__/**
  • apps/resources/__generated__/TranslatedJourney.ts is excluded by !**/__generated__/**
  • apps/watch/__generated__/JourneyAiTranslateCreateSubscription.ts is excluded by !**/__generated__/**
  • apps/watch/__generated__/TranslatedJourney.ts is excluded by !**/__generated__/**
  • libs/journeys/ui/src/libs/useJourneyAiTranslateSubscription/__generated__/JourneyAiTranslateCreateSubscription.ts is excluded by !**/__generated__/**
  • libs/journeys/ui/src/libs/useJourneyAiTranslateSubscription/__generated__/TranslatedJourney.ts is excluded by !**/__generated__/**
📒 Files selected for processing (11)
  • apis/api-gateway/schema.graphql
  • apis/api-journeys-modern/schema.graphql
  • apis/api-journeys-modern/src/schema/block/card/cardBlockUpdate.mutation.spec.ts
  • apis/api-journeys-modern/src/schema/block/card/cardBlockUpdate.mutation.ts
  • apis/api-journeys-modern/src/schema/block/card/index.ts
  • apis/api-journeys/schema.graphql
  • apis/api-journeys/src/app/modules/block/block.module.ts
  • apis/api-journeys/src/app/modules/block/card/card.graphql
  • apis/api-journeys/src/app/modules/block/card/card.resolver.spec.ts
  • apis/api-journeys/src/app/modules/block/card/card.resolver.ts
  • apis/api-journeys/src/app/modules/journey/journey.resolver.spec.ts
💤 Files with no reviewable changes (5)
  • apis/api-journeys/src/app/modules/block/block.module.ts
  • apis/api-journeys/src/app/modules/journey/journey.resolver.spec.ts
  • apis/api-journeys/src/app/modules/block/card/card.graphql
  • apis/api-journeys/src/app/modules/block/card/card.resolver.ts
  • apis/api-journeys/src/app/modules/block/card/card.resolver.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • apis/api-journeys-modern/src/schema/block/card/index.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apis/api-journeys-modern/schema.graphql

Comment on lines +354 to +362
cardBlockCreate(input: CardBlockCreateInput!) : CardBlock! @join__field(graph: API_JOURNEYS_MODERN, override: "api-journeys")
cardBlockUpdate(
id: ID!
input: CardBlockUpdateInput!
"""
drop this parameter after merging teams
"""
journeyId: ID
): CardBlock! @join__field(graph: API_JOURNEYS_MODERN, override: "api-journeys")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf 'Legacy card block mutations in apis/api-journeys/schema.graphql:\n'
rg -n '^\s*cardBlock(Create|Update)\s*\(' apis/api-journeys/schema.graphql || true

printf '\nOverride declarations in the migration path:\n'
rg -n "cardBlock(Create|Update)|override:\s*['\"]api-journeys['\"]" \
  apis/api-gateway/schema.graphql \
  apis/api-journeys-modern/src/schema/block/card

Repository: JesusFilm/core

Length of output: 3280


Remove override: "api-journeys" or restore the legacy mutations.

cardBlockCreate and cardBlockUpdate in the gateway still carry override: "api-journeys", but apis/api-journeys/schema.graphql no longer defines these mutations. The override directive implies a fallback path that no longer exists—this is a hard cutover disguised as a migration. Either restore the mutations in the legacy service to enable true fallback routing, or remove the override declarations to make the service ownership transfer explicit.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apis/api-gateway/schema.graphql` around lines 354 - 362, The gateway schema
still uses `@join__field`(... override: "api-journeys") for the cardBlockCreate
and cardBlockUpdate fields (symbols: cardBlockCreate, cardBlockUpdate,
`@join__field` override: "api-journeys"), but the legacy service no longer exposes
those mutations; remove the override attribute from the `@join__field` directives
on cardBlockCreate and cardBlockUpdate so ownership is explicit (or
alternatively restore the legacy mutations in the legacy service if you need a
fallback), ensuring the gateway no longer references a non-existent override
path.

@github-actions github-actions bot temporarily deployed to Preview - short-links March 21, 2026 00:47 Inactive
@github-actions github-actions bot temporarily deployed to Preview - player March 21, 2026 00:47 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys March 21, 2026 00:47 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch March 21, 2026 00:47 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 21, 2026 00:47 Inactive
@github-actions github-actions bot requested a deployment to Preview - journeys-admin March 21, 2026 00:47 Pending
@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 21, 2026 00:47 Inactive
@github-actions github-actions bot temporarily deployed to Preview - player March 21, 2026 00:53 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys-admin March 21, 2026 00:53 Inactive
@github-actions github-actions bot temporarily deployed to Preview - journeys March 21, 2026 00:53 Inactive
@github-actions github-actions bot temporarily deployed to Preview - resources March 21, 2026 00:53 Inactive
@github-actions github-actions bot temporarily deployed to Preview - short-links March 21, 2026 00:53 Inactive
@github-actions github-actions bot temporarily deployed to Preview - videos-admin March 21, 2026 00:53 Inactive
@github-actions github-actions bot temporarily deployed to Preview - watch March 21, 2026 00:53 Inactive
@blacksmith-sh
Copy link
Contributor

blacksmith-sh bot commented Mar 23, 2026

Found 1 test failure on Blacksmith runners:

Failure

Test View Logs
src/e2e/journeys.spec.ts/journeys View Logs

Fix in Cursor

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.

1 participant