A build tool and Apollo Client network interface for implementing GraphQL query whitelisting and persisted queries (v0.3.11, last release ~2017, no active maintenance). Scans source code for .graphql files and static GraphQL query strings, assigns each query a hash/ID, and produces a JSON mapping. Provides an Apollo Client network interface to send only the hash/ID instead of the full query string. Primarily useful for reducing bandwidth and enforcing query allowlists. Competes with tools like `persisted-query-lib` but is specific to Apollo Client's older architecture. Limited to statically analyzable queries; no support for dynamic queries. Ships TypeScript types.
npm install persistgraphqlVerified import paths — ran on the pinned version, not inferred.
Shows end-to-end setup: CLI to generate query map, client-side network interface integration, and server-side middleware to resolve query IDs.
Consider using 'persisted-query-lib' or Apollo's built-in persisted queries support in Apollo Client >=2.
Ensure all queries are in dedicated .graphql files or use the gql tag in .js/.ts files (requires `--js` flag).
Run `persistgraphql src/ --js --extension=ts`
Include `--add_typename` if you use Apollo Client's cache or fragments that rely on `__typename`.
Upgrade to a modern persisted queries solution such as Apollo Link persisted queries.
npm install graphql
Ensure the same extracted_queries.json is used on both client and server, and that the build step is run before using the map.
Use Apollo Client 1.x or use the package only with that version.
Use: persistgraphql src/ --js --extension=ts
No dependency data recorded yet.