MSW recipes
6 tested MSW integration recipes with graphql-request, graphql, ky, vitest. Exact pinned versions and a last-passed receipt, last run 2026-10-15.
graphql-request client with typed operations, mocked by MSW graphql handlers
Call a GraphQL API with graphql-request (variables, headers, error handling) and test offline with MSW's graphql.link(url).query/mutation handlers (msw 3 API). graphql stays on 16.x: graphql-request 7 peers on graphql 14 - 16.
ky HTTP client with hooks and retries, tested with MSW + Vitest
A ky 2 API client (prefix option, state-object hooks) with auth hooks, retry on 5xx and typed JSON, tested offline with MSW's Node server in Vitest.
ofetch HTTP client mocked with MSW
Call APIs with ofetch against an MSW 2 HTTP worker in Node, covering JSON responses, query params and error status mapping offline.
Redux Toolkit + RTK Query with tag invalidation and optimistic updates, tested with MSW
An RTK Query API slice with auth headers from Redux state, tag-based cache invalidation and an optimistic update with rollback, tested offline in Vitest against MSW 3 request handlers without rendering React.
Resend email sending with React-free templates, tested with MSW
Send transactional email with the Resend Node SDK (HTML + text, tags, idempotency), handling API errors, tested offline by intercepting the Resend API with MSW.
Typed fetch API client tested with MSW + Zod
A typed fetch client that parses responses with Zod, tested offline by intercepting requests with MSW's Node server.
Used together with MSW
graphql-requestgraphqlkyvitestofetch@reduxjs/toolkitresendZod