Skip to content

Add Order.totalAmount and deprecate Order.total - #6

Open
mtyates wants to merge 1 commit into
mainfrom
add-order-total-amount
Open

mtyates wants to merge 1 commit into
mainfrom
add-order-total-amount

Conversation

@mtyates

@mtyates mtyates commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Introduces Order.totalAmount as the replacement for Order.total, following docs/schema-guidelines.md (deprecate, migrate, then remove).

  • Adds Order.totalAmount (same value, USD)
  • Marks Order.total @deprecated(reason: "Use totalAmount.")
  • Test asserts both fields stay equal until removal
  • CHANGELOG updated

Client migrations will follow in thicket-web and thicket-mobile.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added totalAmount to orders, providing the computed order total in queries.
  • Updates

    • Marked the existing total field as deprecated and identified totalAmount as its replacement.
    • Updated the example orders query to use totalAmount.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between e1f5d6f and 581222e.

Files selected for processing: 5
  • CHANGELOG.md
  • README.md
  • schema/schema.graphql
  • src/resolvers/index.ts
  • test/orders.test.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 6 remain after this review.

Walkthrough

The Order GraphQL type adds totalAmount and deprecates total. The resolver returns the computed order total for the new field. The example query and tests now use or verify totalAmount.

Changes

Order totalAmount

Layer / File(s) Summary
Add the Order totalAmount field
schema/schema.graphql, src/resolvers/index.ts
The schema adds non-null totalAmount and deprecates total. The new resolver returns the computed order total.
Update examples and verification
README.md, test/orders.test.ts, CHANGELOG.md
The README query and order tests use totalAmount. A test checks that total and totalAmount match. The changelog records the addition and deprecation.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Feature

Merge Risk: Minimal · up to 58122

The new field preserves existing clients and is verified through the GraphQL endpoint.

Security architecture risk: Minimal · up to 58122

The new field exposes the same computed amount through the existing order access path. The old field remains compatible, and the reviewed change introduces no new access privileges, sensitive data, or state transitions.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The incremental exposure is another selectable name for an already exposed order amount. The reviewed change does not broaden the set of reachable orders or introduce access to another tenant, service, or data store.

Trust Boundaries and Controls

  • observed — The inspected order path uses direct store lookup without an authorization check. That behavior predates this PR and is unchanged: totalAmount adds neither a new query entrypoint nor an identity or privilege transition. The selected test range exercises the existing GraphQL endpoint rather than introducing a production route.
Pre-merge checks: Passed 9
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title uses the imperative mood, is 47 characters long, and clearly describes the user-visible API change.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within survi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Linked Consumer Compatibility Passed PASS. The PR keeps Order.total: Float! and its resolver value unchanged, and adds Order.totalAmount: Float! with the same computed value (schema/schema.graphql:65-68; `src/resolvers/index.ts:77-…
Schema Evolution Policy Passed The schema change is compatible. Order.totalAmount: Float! is added, and Order.total remains with @deprecated(reason: "Use totalAmount.") in schema/schema.graphql (lines 65-68). No field, argu…
Behavioral Contract Changes Passed No existing field changes meaning. Order.total keeps type Float!, its USD description, and the same computeTotals(order.items).total resolver; the PR only adds totalAmount with the same comput…
Contract Test Coverage Passed The schema adds Order.totalAmount and deprecates Order.total in schema/schema.graphql:52-68. The resolver implements both fields in src/resolvers/index.ts:77-81. Updated tests in `test/orders.…
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files. (3 skipped: 3 unsupported.)

Full details: Linked Consumer Compatibility

Explanation

PASS. The PR keeps Order.total: Float! and its resolver value unchanged, and adds Order.totalAmount: Float! with the same computed value (schema/schema.graphql:65-68; src/resolvers/index.ts:77-81). No argument, input field, or enum value changed. The linked consumers were readable. Checked web OrderSummary and operations OrderHistory, OrderDetail, Checkout, and RefundOrder in mtyates-coderabbit/thicket-web at commit 1cbdcd3862b6c67fd3a35b3ef2c4129de015f5fb. Checked mobile OrderCard and operations MyOrders, OrderReceipt, and PlaceOrder in mtyates-coderabbit/thicket-mobile at commit 96b1cd8a3d65b812e348b2174b9dd7fbd9296934. These consumers still select the retained deprecated total field. Their TypeScript types keep total non-null, so no nullable-read issue applies.

Full details: Schema Evolution Policy

Explanation

The schema change is compatible. Order.totalAmount: Float! is added, and Order.total remains with @deprecated(reason: "Use totalAmount.") in schema/schema.graphql (lines 65-68). No field, argument, or enum value is removed or renamed in place. No required argument or input field is added. The new resolver returns computeTotals(order.items).total; computeTotals returns a number, so the new non-null field is not nullable at runtime.

Full details: Behavioral Contract Changes

Explanation

No existing field changes meaning. Order.total keeps type Float!, its USD description, and the same computeTotals(order.items).total resolver; the PR only adds totalAmount with the same computation (schema/schema.graphql:65-68, src/resolvers/index.ts:77-81). Pricing still rounds USD values to cents (src/domain/pricing.ts:14-27), and checkout stores payment amounts from the same total (src/domain/checkout.ts:40-63). The added test also checks total equals totalAmount (test/orders.test.ts:43-48).

Full details: Contract Test Coverage

Explanation

The schema adds Order.totalAmount and deprecates Order.total in schema/schema.graphql:52-68. The resolver implements both fields in src/resolvers/index.ts:77-81. Updated tests in test/orders.test.ts:4-49 query both fields and assert their values. test/helpers.ts:9-19 creates the app with createApp() and executes GraphQL requests, so the changed behavior has contract test coverage.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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