{"library":"persistgraphql","title":"PersistGraphQL","description":"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.","language":"javascript","status":"deprecated","last_verified":"Sat Apr 25","install":{"commands":["npm install persistgraphql"],"cli":{"name":"persistgraphql","version":null}},"imports":["import { addPersistedQueries } from 'persistgraphql'","import * as persistgraphql from 'persistgraphql'","import type { OutputMap } from 'persistgraphql'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"// Build the query map: persists queries from .graphql files into extracted_queries.json\n// CLI: persistgraphql src/ output.json --add_typename\n\n// On the client (Apollo Client 1.x)\nimport { createNetworkInterface } from 'apollo-client';\nimport { addPersistedQueries } from 'persistgraphql';\nimport queryMap from './extracted_queries.json';\n\nconst networkInterface = createNetworkInterface({ uri: '/graphql' });\naddPersistedQueries(networkInterface, queryMap);\n\n// On the server (e.g., Express)\nimport queryMap from './extracted_queries.json';\nimport { invert } from 'lodash';\nconst invertedMap = invert(queryMap);\napp.use('/graphql', (req, res, next) => {\n  if (req.body.id) {\n    req.body.query = invertedMap[req.body.id];\n  }\n  next();\n});","lang":"typescript","description":"Shows end-to-end setup: CLI to generate query map, client-side network interface integration, and server-side middleware to resolve query IDs.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}