Skip to content
Source
Sign inSign up
TanStack/query

docs(angular-query): improve mutationOptions jsdoc code example #9648

Mergedarnoud-dv(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/9648/headmerged by arnoud-dv(GitHub profile, opens in a new tab) View on GitHub

Clarify that it's inside a class - if AI tooling doesn't understand that it's confusing for humans too.

Summary by CodeRabbit

  • Documentation
    • Improved API examples to demonstrate usage within a class context, clarifying how to set up dependencies, define a mutation, and invoke it from an instance (e.g., this.mutation.mutate).
    • Examples now better reflect common component/service patterns for easier adoption.
    • No functional or API changes; this is a docs-only update aimed at clearer guidance for real-world integration.
    1. Warning

      Rate limit exceeded

      @arnoud-dv has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 3 minutes and 45 seconds before requesting another review.

      ⌛ 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.

      📥 Commits

      Reviewing files that changed from the base of the PR and between bbda462667e3744ff64c1ef5d1a8ac0930deb79e and 4e13e5d8b1d7057cf5c2b94999129beea9470b55.

      📒 Files selected for processing (1)
      • packages/angular-query-experimental/src/mutation-options.ts (2 hunks)

      Walkthrough

      Documentation-only edits in packages/angular-query-experimental/src/mutation-options.ts: JSDoc examples were updated to demonstrate usage within a class context, using injected QueriesService, an idSignal, and injectMutation. No code logic, types, or public APIs changed.

      Changes

      Cohort / File(s)Summary
      JSDoc example updates
      packages/angular-query-experimental/src/mutation-options.ts
      Revised two JSDoc examples to wrap usage in a class (ComponentOrService) with injected QueriesService, idSignal, and injectMutation; updated invocation from mutation.mutate(...) to this.mutation.mutate(...). No runtime or type changes.

      Estimated code review effort

      🎯 1 (Trivial) | ⏱️ ~3 minutes

      Suggested labels

      documentation

      Poem

      I nibbled on docs with a gentle hop, Wrapped examples snug in a classy shop. Inject, mutate—now tidy and bright, No logic disturbed in the moonlit night. Thump-thump! says the reviewer’s paw— Carrots for style, and zero code law. 🥕

      ✨ Finishing touches
      • 📝 Generate Docstrings
        🧪 Generate unit tests
      • Create PR with unit tests
      • Post copyable unit tests in a comment
      • Commit unit tests in branch `docs/angular-query-improve-mutation-options-jsdoc`

      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.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: angular-query-experimental

    3. View your CI Pipeline Execution ↗ for commit 4e13e5d8b1d7057cf5c2b94999129beea9470b55

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded1m 47sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded10sView ↗

      ☁️ Nx Cloud last updated this comment at 2025-09-12 15:09:19 UTC

    4. More templates

      @tanstack/angular-query-devtools-experimental

      npm i https://pkg.pr.new/@tanstack/angular-query-devtools-experimental@9648

      @tanstack/angular-query-experimental

      npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9648

      @tanstack/eslint-plugin-query

      npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9648

      @tanstack/query-async-storage-persister

      npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9648

      @tanstack/query-broadcast-client-experimental

      npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9648

      @tanstack/query-core

      npm i https://pkg.pr.new/@tanstack/query-core@9648

      @tanstack/query-devtools

      npm i https://pkg.pr.new/@tanstack/query-devtools@9648

      @tanstack/query-persist-client-core

      npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9648

      @tanstack/query-sync-storage-persister

      npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9648

      @tanstack/react-query

      npm i https://pkg.pr.new/@tanstack/react-query@9648

      @tanstack/react-query-devtools

      npm i https://pkg.pr.new/@tanstack/react-query-devtools@9648

      @tanstack/react-query-next-experimental

      npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9648

      @tanstack/react-query-persist-client

      npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9648

      @tanstack/solid-query

      npm i https://pkg.pr.new/@tanstack/solid-query@9648

      @tanstack/solid-query-devtools

      npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9648

      @tanstack/solid-query-persist-client

      npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9648

      @tanstack/svelte-query

      npm i https://pkg.pr.new/@tanstack/svelte-query@9648

      @tanstack/svelte-query-devtools

      npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9648

      @tanstack/svelte-query-persist-client

      npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9648

      @tanstack/vue-query

      npm i https://pkg.pr.new/@tanstack/vue-query@9648

      @tanstack/vue-query-devtools

      npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9648

      commit: 4e13e5d

    5. Sizes for commit 4e13e5d8b1d7057cf5c2b94999129beea9470b55:

      BranchBundle Size
      Main
      This PR
    6. Codecov Report

      :white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 87.77%. Comparing base (d179168) to head (4e13e5d). :warning: Report is 2 commits behind head on main.

      Additional details and impacted files

      Impacted file tree graph

      @@             Coverage Diff             @@
      ##             main    #9648       +/-   ##
      ===========================================
      + Coverage   45.51%   87.77%   +42.25%     
      ===========================================
        Files         209       16      -193     
        Lines        8379      319     -8060     
        Branches     1905       75     -1830     
      ===========================================
      - Hits         3814      280     -3534     
      + Misses       4118       34     -4084     
      + Partials      447        5      -442     
      ComponentsCoverage Δ
      @tanstack/angular-query-devtools-experimental∅ <ø> (∅)
      @tanstack/angular-query-experimental87.00% <ø> (ø)
      @tanstack/eslint-plugin-query∅ <ø> (∅)
      @tanstack/query-async-storage-persister∅ <ø> (∅)
      @tanstack/query-broadcast-client-experimental∅ <ø> (∅)
      @tanstack/query-codemods∅ <ø> (∅)
      @tanstack/query-core∅ <ø> (∅)
      @tanstack/query-devtools∅ <ø> (∅)
      @tanstack/query-persist-client-core∅ <ø> (∅)
      @tanstack/query-sync-storage-persister∅ <ø> (∅)
      @tanstack/query-test-utils∅ <ø> (∅)
      @tanstack/react-query∅ <ø> (∅)
      @tanstack/react-query-devtools∅ <ø> (∅)
      @tanstack/react-query-next-experimental∅ <ø> (∅)
      @tanstack/react-query-persist-client∅ <ø> (∅)
      @tanstack/solid-query∅ <ø> (∅)
      @tanstack/solid-query-devtools∅ <ø> (∅)
      @tanstack/solid-query-persist-client∅ <ø> (∅)
      @tanstack/svelte-query∅ <ø> (∅)
      @tanstack/svelte-query-devtools∅ <ø> (∅)
      @tanstack/svelte-query-persist-client∅ <ø> (∅)
      @tanstack/vue-query∅ <ø> (∅)
      @tanstack/vue-query-devtools∅ <ø> (∅)
      :rocket: New features to boost your workflow:
      • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
      • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
  • Actionable comments posted: 2

    📜 Review details

    Configuration used: CodeRabbit UI

    Review profile: CHILL

    Plan: Pro

    📥 Commits

    Reviewing files that changed from the base of the PR and between e3b40d4d0daaf44fadf7aac0a7fa5fea91361442 and bbda462667e3744ff64c1ef5d1a8ac0930deb79e.

    📒 Files selected for processing (1)
    • packages/angular-query-experimental/src/mutation-options.ts (2 hunks)
    ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
    • GitHub Check: Preview
    • GitHub Check: Test
    @@ -81,8 +83,10 @@
    8183 * }
    8284 * }
    8385 *
    84- * queries = inject(QueriesService)
    85- * idSignal = new Signal(0);
    86- * mutation = injectMutation(() => this.queries.updatePost(this.idSignal()))
    86+ * class ComponentOrService {
    87+ * queries = inject(QueriesService)
    88+ * idSignal = new Signal(0);
    89+ * mutation = injectMutation(() => this.queries.updatePost(this.idSignal()))
    90+ * }
    8791 *
    88- * mutation.mutate({ title: 'New Title' })
    92+ * this.mutation.mutate({ title: 'New Title' })

    ⚠️ Potential issue

    Duplicate snippet: apply the same fixes here

    Mirror the same corrections: use signal(0), keep mutate inside the class (e.g., save()), and add semicolons.

    - class ComponentOrService {
    -   queries = inject(QueriesService)
    -   idSignal = new Signal(0);
    -   mutation = injectMutation(() => this.queries.updatePost(this.idSignal()))
    - }
    -
    - this.mutation.mutate({ title: 'New Title' })
    + class ComponentOrService {
    +   queries = inject(QueriesService);
    +   idSignal = signal(0);
    +   mutation = injectMutation(() => this.queries.updatePost(this.idSignal()));
    +
    +   save() {
    +     this.mutation.mutate({ title: 'New Title' });
    +   }
    + }

    Note: the snippet assumes import { inject, signal } from '@angular/core'.

    📝 Committable suggestion

    ‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

     * class ComponentOrService {
     *   queries = inject(QueriesService);
     *   idSignal = signal(0);
     *   mutation = injectMutation(() => this.queries.updatePost(this.idSignal()));
     *
     *   save() {
     *     this.mutation.mutate({ title: 'New Title' });
     *   }
     * }
    🤖 Prompt for AI Agents
    In packages/angular-query-experimental/src/mutation-options.ts around lines 86
    to 92, the example uses the old `new Signal(0)` pattern, places `mutate` call
    outside a class method, and is missing semicolons; change `new Signal(0)` to
    `signal(0)`, keep the mutate invocation inside the class (e.g., implement a
    `save()` method that calls `this.mutation.mutate({...});`), add missing
    semicolons to statements, and ensure the example notes the required import
    `import { inject, signal } from '@angular/core'`.
  • Sign in to join this conversation.