{"id":20630704,"url":"https://github.com/sysgears/apollo-cache-router","last_synced_at":"2025-04-15T18:22:41.176Z","repository":{"id":57182275,"uuid":"129703843","full_name":"sysgears/apollo-cache-router","owner":"sysgears","description":"Apollo GraphQL Cache Router","archived":false,"fork":false,"pushed_at":"2018-11-14T09:28:33.000Z","size":31,"stargazers_count":7,"open_issues_count":1,"forks_count":1,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-03-04T17:48:56.965Z","etag":null,"topics":["apollo","apollo-client","graphql"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sysgears.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-16T07:38:17.000Z","updated_at":"2019-05-16T05:30:48.000Z","dependencies_parsed_at":"2022-09-14T06:10:50.561Z","dependency_job_id":null,"html_url":"https://github.com/sysgears/apollo-cache-router","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fapollo-cache-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fapollo-cache-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fapollo-cache-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sysgears%2Fapollo-cache-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sysgears","download_url":"https://codeload.github.com/sysgears/apollo-cache-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249126461,"owners_count":21216786,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo","apollo-client","graphql"],"created_at":"2024-11-16T14:09:20.065Z","updated_at":"2025-04-15T18:22:41.149Z","avatar_url":"https://github.com/sysgears.png","language":"TypeScript","readme":"## Apollo Cache Router\n\n[![npm version](https://badge.fury.io/js/apollo-cache-router.svg)](https://badge.fury.io/js/apollo-cache-router)\n[![Twitter Follow](https://img.shields.io/twitter/follow/sysgears.svg?style=social)](https://twitter.com/sysgears)\n\n## Installation\n\n```bash\nnpm install --save-dev apollo-cache-router\n```\n\n## Usage\n``` js\nimport { InMemoryCache } from 'apollo-cache-inmemory';\nimport ApolloCacheRouter from 'apollo-cache-router';\nimport { hasDirectives } from 'apollo-utilities';\n\nconst netCache = new InMemoryCache();\nconst localCache = new InMemoryCache();\nconst cache = ApolloCacheRouter.override(\n  ApolloCacheRouter.route([netCache, localCache], document =\u003e {\n    const operationName = getOperationAST(document).name;\n    if (hasDirectives(['client'], document)\n        || (operationName \u0026\u0026 operationName.value === 'GeneratedClientQuery')) {\n      // Pass all @client queries and @client defaults to localCache\n      return [localCache];\n    } else {\n      // Pass all the other queries to netCache\n      return [netCache];\n    }\n  }),\n  {\n    reset: () =\u003e {\n      // On apolloClient.resetStore() reset only netCache and keep localCache intact\n      return netCache.reset();\n    }\n  }\n);\n```\n\n### Logging\nIf you want log cache access and errors please check [`apollo-cache-logger`](https://github.com/sysgears/apollo-cache-logger)\n\n## License\nCopyright © 2018 [SysGears LTD]. This source code is licensed under the [MIT] license.\n\n[MIT]: LICENSE\n[SysGears LTD]: http://sysgears.com\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysgears%2Fapollo-cache-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsysgears%2Fapollo-cache-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsysgears%2Fapollo-cache-router/lists"}