{"id":26267238,"url":"https://github.com/oslabs-beta/loql","last_synced_at":"2025-04-30T19:08:24.103Z","repository":{"id":46886042,"uuid":"395728642","full_name":"oslabs-beta/loQL","owner":"oslabs-beta","description":"loQL is a lightweight, open source npm package that caches API requests with service workers, unlocking performance gains and enabling offline use.","archived":false,"fork":false,"pushed_at":"2021-09-22T01:41:51.000Z","size":378,"stargazers_count":48,"open_issues_count":1,"forks_count":17,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-30T19:06:54.124Z","etag":null,"topics":["caching","graphql","indexeddb","javascript","service-worker"],"latest_commit_sha":null,"homepage":"https://loql.land","language":"JavaScript","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/oslabs-beta.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":"2021-08-13T16:56:06.000Z","updated_at":"2024-07-30T08:45:10.000Z","dependencies_parsed_at":"2022-09-18T04:20:59.812Z","dependency_job_id":null,"html_url":"https://github.com/oslabs-beta/loQL","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/oslabs-beta%2FloQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2FloQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2FloQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oslabs-beta%2FloQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oslabs-beta","download_url":"https://codeload.github.com/oslabs-beta/loQL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251767193,"owners_count":21640468,"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":["caching","graphql","indexeddb","javascript","service-worker"],"created_at":"2025-03-14T04:16:11.082Z","updated_at":"2025-04-30T19:08:24.080Z","avatar_url":"https://github.com/oslabs-beta.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# loQL\n\nA light, modular npm package for performant client-side GraphQL caching with Service Workers and IndexedDB. More detailed information about installing and configuring loQL can be found \u003ca href=\"https://loql.land/docs\"\u003ehere\u003c/a\u003e.\n\n## Installation\n\nInstall via [npm](https://www.npmjs.com/package/loql-cache) \n\n```bash\nnpm install loql-cache\n```\nOr with Yarn\n\n```bash\nyarn add loql-cache\n```\n\nThe service worker must also be included in your build folder. With webpack:\n\n```javascript\nconst path = require('path');\n\nmodule.exports = {\n  entry: {\n    bundle: './client/index.js',\n    loQL: './node_modules/loql-cache/loQL.js', // Add this line!\n  },\n  output: {\n  path: path.resolve(__dirname, 'public'),\n    filename: '[name].js',\n    clean: true,\n  },\n  devServer: {\n    static: './client',\n  },\n};\n```\n\n## Register the service worker\n\n```javascript\nimport { register } from \"loql-cache\";\nregister({ gqlEndpoints: [\"https://foo.com\"] });\n```\n\n## Settings\n\n\n`gqlEndpoints: string[] Required`\n\nEnable caching for specific GraphQL endpoint URLs. Network calls from the browser to any URL not listed here will be ignored by the service worker and the response data will not be cached.\n\n`useMetrics: boolean Optional`\n\nEnable metrics collection. \n\n`cacheMethod: string Optional`\n\nDesired caching strategy. The loql-cache package supports both \"cache-first\" and \"cache-network\" policies.\n\n`cacheExpirationLimit: Integer Optional`\n\nThe interval, in milliseconds, after which cached data is considered stale. \n\n`doNotCacheGlobal: string[] Optional`\n\nFields on a GraphQL query that will prevent the query from being cached, no matter the endpoint.\n\n`doNotCacheCustom:{ [url]: string[] } Optional`\n\nThis setting is like doNotCacheGlobal, but can be used on a per-endpoint basis.\n\n### Example Configuration\n\n```javascript\nconst loQLConfiguration = {\n  gqlEndpoints: ['http://localhost:\u003c###\u003e/api/graphql', 'https://\u003cabc\u003e.com/graphql'],\n  useMetrics: false,\n  cacheExpirationLimit: 20000,\n  cacheMethod: 'cache-network',\n  doNotCacheGlobal: [],\n  doNotCacheCustom: {\n     'http://localhost:\u003c###\u003e/api/graphql': ['password'],\n     'https://\u003cabc\u003e.com/graphql': ['account', 'real_time_data'];\n  }\n};\n\nregister(loqlConfiguration);\n```\n\n## Features\n- Enables offline use: IndexedDB storage provides high-capacity and persistent storage, while keeping reads/writes asynchronous\n- Minimum-dependency: No server-side component, avoid the use of large libraries\n- Cache validation: Keep data fresh with shorter expiration limits, cache-network strategy, or both!\n- Easy-to-use: Install package, register and configure service worker, start caching\n- Flexible: Works with GQL queries made as both fetch POST and GET requests\n- Easily exempt types of queries from being cached at the global or endpoint-specific level\n\n## Usage Notes\n- Caching is currently only supported for query-type operations. Mutations, subscriptions, etc will still run,\n  but will not be cached. \n- Cached data normalization feature is disabled.\n\n## Contributing\nContributions are welcome. Please read CONTRIBUTE.md prior to making a Pull Request.\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foslabs-beta%2Floql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foslabs-beta%2Floql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foslabs-beta%2Floql/lists"}