A GraphQL code generator plugin that automatically creates typed SWR hooks (useSWR, useSWRInfinite) from GraphQL operations. Version 0.8.5, actively maintained. Integrates with graphql-request and the GraphQL Codegen ecosystem. Unlike manual SWR wrapping, it auto-generates hooks with optimal caching keys and supports pagination, custom keys, and exclusion patterns. Requires graphql <17, and peer dependency on graphql-codegen typescript plugins. Ships TypeScript types.
npm install graphql-codegen-plugin-typescript-swrNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to generate a typed SWR hook and use it in a React component.
Downgrade graphql to ^16.0.0 or use an alternative plugin.
Always pass a string key: sdk.useQueryName('myKey').Evaluate if the package is still maintained, and consider migrating if necessary.
Run graphql-codegen and ensure the import path matches the 'generates' output in your codegen.yml.
Check your codegen config: ensure the query is not excluded and is named correctly in the .graphql files.
Add the query name to the useSWRInfinite list in your codegen.yml under config.