Skip to content

test(solid-query/useMutation): add tests for 'MutationFunctionContext' passed to mutationFn and callbacks - #11441

Merged
sukvvon merged 1 commit into
mainfrom
test/solid-mutation-context-coverage
Sep 8, 2026
Merged

test(solid-query/useMutation): add tests for 'MutationFunctionContext' passed to mutationFn and callbacks#11441
sukvvon merged 1 commit into
mainfrom
test/solid-mutation-context-coverage

Conversation

@sukvvon

@sukvvon sukvvon commented Sep 8, 2026

Copy link
Copy Markdown
Member

🎯 Changes

Adds test coverage for MutationFunctionContext (the { client, meta, mutationKey } object passed as the last argument to mutationFn and every mutation callback) in solid-query's useMutation.test.tsx and useMutation.test-d.tsx, mirroring the coverage added for react-query/preact-query in #11440.

Runtime tests added:

  • hook-level onSuccess receiving a non-undefined onMutateResult alongside context
  • mutationFn accessing the same QueryClient instance via context.client
  • context.mutationKey reflecting the mutationKey passed to useMutation
  • context.client.invalidateQueries() actually invalidating the cache from within onSuccess

Type tests added:

  • context typed as MutationFunctionContext for mutationFn and every hook-level callback, and context.client typed as @tanstack/query-core's QueryClient (not solid-query's QueryClient subclass — MutationFunctionContext is non-generic)
  • context typed as MutationFunctionContext for every per-call mutate option
  • context.mutationKey typed as MutationKey | undefined

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Tests
    • Expanded mutation testing to verify that mutation functions and callbacks receive the expected execution context.
    • Added coverage for access to the query client, mutation key, and results returned by mutation setup callbacks.
    • Verified that mutation callbacks can use the provided client to invalidate queries.

@nx-cloud

nx-cloud Bot commented Sep 8, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit e0809bc

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 4m 47s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 6s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-08 00:55:17 UTC

@sukvvon
sukvvon force-pushed the test/solid-mutation-context-coverage branch from e0809bc to 0bfde39 Compare September 8, 2026 00:48
@sukvvon sukvvon changed the title test(solid-query/useMutation): add coverage for 'MutationFunctionContext' passed to mutationFn and callbacks test(solid-query/useMutation): add tests for 'MutationFunctionContext' passed to mutationFn and callbacks Sep 8, 2026
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

2 package(s) bumped directly, 23 bumped as dependents.

🟨 Minor bumps

Package Version Reason
@tanstack/query-core 5.102.8 → 5.103.0 Changeset
@tanstack/svelte-query 6.1.48 → 6.2.0 Changeset
@tanstack/angular-query-experimental 5.102.8 → 5.103.0 Dependent
@tanstack/angular-query-persist-client 5.102.8 → 5.103.0 Dependent
@tanstack/eslint-plugin-query 5.102.8 → 5.103.0 Dependent
@tanstack/preact-query 5.102.8 → 5.103.0 Dependent
@tanstack/preact-query-devtools 5.102.8 → 5.103.0 Dependent
@tanstack/preact-query-persist-client 5.102.8 → 5.103.0 Dependent
@tanstack/query-async-storage-persister 5.102.8 → 5.103.0 Dependent
@tanstack/query-broadcast-client-experimental 5.102.8 → 5.103.0 Dependent
@tanstack/query-devtools 5.102.8 → 5.103.0 Dependent
@tanstack/query-persist-client-core 5.102.8 → 5.103.0 Dependent
@tanstack/query-sync-storage-persister 5.102.8 → 5.103.0 Dependent
@tanstack/react-query 5.102.8 → 5.103.0 Dependent
@tanstack/react-query-devtools 5.102.8 → 5.103.0 Dependent
@tanstack/react-query-next-experimental 5.102.8 → 5.103.0 Dependent
@tanstack/react-query-persist-client 5.102.8 → 5.103.0 Dependent
@tanstack/solid-query 5.102.8 → 5.103.0 Dependent
@tanstack/solid-query-devtools 5.102.8 → 5.103.0 Dependent
@tanstack/solid-query-persist-client 5.102.8 → 5.103.0 Dependent
@tanstack/svelte-query-devtools 6.1.48 → 6.2.0 Dependent
@tanstack/svelte-query-persist-client 6.1.48 → 6.2.0 Dependent
@tanstack/vue-query 5.102.8 → 5.103.0 Dependent
@tanstack/vue-query-devtools 6.1.48 → 6.2.0 Dependent

🟩 Patch bumps

Package Version Reason
@tanstack/lit-query 0.2.20 → 0.2.21 Dependent

@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 8915b5fa-a218-4e53-8d7c-cefa65039ee7

📥 Commits

Reviewing files that changed from the base of the PR and between e57f816 and 0bfde39.

📒 Files selected for processing (2)
  • packages/solid-query/src/__tests__/useMutation.test-d.tsx
  • packages/solid-query/src/__tests__/useMutation.test.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The changes add type-level and runtime tests for MutationFunctionContext in Solid Query mutations. The tests cover callback argument types, client access, mutation keys, transformed data, onMutate results, and query invalidation.

Changes

Mutation context coverage

Layer / File(s) Summary
Mutation context type contracts
packages/solid-query/src/__tests__/useMutation.test-d.tsx
Type tests verify context arguments for mutation functions, hook callbacks, and per-call callbacks. They also verify context.client and context.mutationKey types.
Mutation context runtime behavior
packages/solid-query/src/__tests__/useMutation.test.tsx
Runtime tests verify client access, mutation keys, onMutate results, transformed data, and query invalidation through context.client.

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

Merge Risk: ⚪ Minimal · up to 0bfde

This change adds Solid Query tests for mutation callback context propagation, client access, mutation keys, and invalidation behavior without changing published runtime code. No current merge-readiness risk remains.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the Solid Query scope and the added tests for MutationFunctionContext passed to mutationFn and callbacks.
Description check ✅ Passed The description follows the repository template. It explains the changes, lists runtime and type coverage, completes the checklist, and identifies the change as docs/CI/dev-only with no release impact…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/solid-mutation-context-coverage

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.

@sukvvon sukvvon self-assigned this Sep 8, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 8, 2026

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

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

@tanstack/eslint-plugin-query

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

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11441

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@11441

@tanstack/preact-query-devtools

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

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11441

@tanstack/query-async-storage-persister

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

@tanstack/query-broadcast-client-experimental

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

@tanstack/query-core

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

@tanstack/query-devtools

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

@tanstack/query-persist-client-core

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

@tanstack/query-sync-storage-persister

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

@tanstack/react-query

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

@tanstack/react-query-devtools

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

@tanstack/react-query-next-experimental

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

@tanstack/react-query-persist-client

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

@tanstack/solid-query

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

@tanstack/solid-query-devtools

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

@tanstack/solid-query-persist-client

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

@tanstack/svelte-query

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

@tanstack/svelte-query-devtools

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

@tanstack/svelte-query-persist-client

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

@tanstack/vue-query

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

@tanstack/vue-query-devtools

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

commit: 0bfde39

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
react full 11.85 KB (0%)
react minimal 8.84 KB (0%)

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