graphql-codegen-urql-persisted-query-map
v0.0.1
Published
A GraphQL Codegen plugin that generates a mapping of SHA256 hashes to query strings, compatible with URQL persisted queries.
Downloads
3
Readme
graphql-codegen-urql-persisted-query-map
A GraphQL Codegen plugin that generates a mapping of SHA256 hashes to query strings, compatible with URQL persisted queries.
Features
- Adds
__typenameto all nested selection sets (except root Query/Mutation). - Outputs a JSON object mapping SHA256 hashes to query strings.
- Designed for use with URQL and persisted queries.
- Written in TypeScript
Installation
npm add -D graphql-codegen-urql-persisted-query-mapUsage
Integrate this plugin with your GraphQL Codegen configuration to generate a persisted query map for your URQL client.
import type { CodegenConfig } from '@graphql-codegen/cli'
const config: CodegenConfig = {
// ...
generates: {
'persisted-queries.json': {
plugins: ['graphql-codegen-urql-persisted-query-map'],
},
},
}This plugin automatically adds __typename to all selection sets except for root Query and Mutation operations, ensuring compatibility with URQL's caching and normalization.
Development
- Requires Node.js and pnpm
- Main logic is in
index.ts.
License
MIT
