{"id":17961137,"url":"https://github.com/matissjanis/apollo-server-cache-sql","last_synced_at":"2026-04-12T11:46:06.297Z","repository":{"id":57182387,"uuid":"266418440","full_name":"MatissJanis/apollo-server-cache-sql","owner":"MatissJanis","description":"Minimalistic Apollo Server SQL Cache driver","archived":false,"fork":false,"pushed_at":"2020-07-20T21:40:40.000Z","size":141,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-02T05:13:51.322Z","etag":null,"topics":["apollo","apollo-server","cache","graphql","nodejs","sql"],"latest_commit_sha":null,"homepage":null,"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/MatissJanis.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":"2020-05-23T20:58:19.000Z","updated_at":"2021-03-02T19:49:27.000Z","dependencies_parsed_at":"2022-09-14T06:00:28.685Z","dependency_job_id":null,"html_url":"https://github.com/MatissJanis/apollo-server-cache-sql","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatissJanis%2Fapollo-server-cache-sql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatissJanis%2Fapollo-server-cache-sql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatissJanis%2Fapollo-server-cache-sql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatissJanis%2Fapollo-server-cache-sql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatissJanis","download_url":"https://codeload.github.com/MatissJanis/apollo-server-cache-sql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247060840,"owners_count":20877158,"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-server","cache","graphql","nodejs","sql"],"created_at":"2024-10-29T11:08:23.805Z","updated_at":"2025-10-12T06:39:24.566Z","avatar_url":"https://github.com/MatissJanis.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Apollo Server SQL Cache driver\n\n[![npm version](https://badge.fury.io/js/apollo-server-cache-sql.svg)](https://badge.fury.io/js/apollo-server-cache-sql)\n![Build and Deploy](https://github.com/MatissJanis/apollo-server-cache-sql/workflows/Build%20and%20Deploy/badge.svg)\n[![codecov](https://codecov.io/gh/MatissJanis/apollo-server-cache-sql/branch/master/graph/badge.svg)](https://codecov.io/gh/MatissJanis/apollo-server-cache-sql)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/b26c27961c3b46df93d3cccf4bbc366e)](https://www.codacy.com/manual/matiss/apollo-server-cache-sql?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=MatissJanis/apollo-server-cache-sql\u0026utm_campaign=Badge_Grade)\n[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)\n[![npm](https://img.shields.io/npm/l/apollo-server-cache-sql.svg)](https://www.npmjs.com/package/apollo-server-cache-sql)\n\nMinimalistic Apollo Server SQL Cache driver for times when [Redis](https://github.com/apollographql/apollo-server/blob/master/packages/apollo-server-cache-redis) or other more modern caching solutions are too expensive or unavailable.\n\n## Installing\n\n```sh\nnpm install --save-dev apollo-server-cache-sql\n# or\nyarn add -D apollo-server-cache-sql\n```\n\n## Setup\n\nA SQL table for cache artifact storage must be created. The following is a blueprint for a basic caching table.\n\n```sql\nCREATE TABLE `cache` (\n  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n  `key` varchar(255) DEFAULT NULL,\n  `value` longtext,\n  `ttl` int(11) DEFAULT NULL,\n  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,\n  PRIMARY KEY (`id`),\n  UNIQUE KEY `key` (`key`)\n) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;\n```\n\n## Usage\n\n```js\nimport mysql from 'mysql';\nimport { SqlCache } from 'apollo-server-cache-sql';\n\n// Setup the connection client\nconst connection = mysql.createConnection({\n  host: 'localhost',\n  user: 'me',\n  password: 'secret',\n  database: 'my_db',\n});\nconnection.connect();\n\n// Setup Apollo Server with SQL cache driver\nconst server = new ApolloServer({\n  typeDefs,\n  resolvers,\n  cache: new SqlCache({\n    client: connection,\n    databaseName: 'my_db',\n    tableName: 'cache',\n  }),\n  dataSources: () =\u003e ({\n    moviesAPI: new MoviesAPI(),\n  }),\n});\n```\n\n### Usage with full-query caching\n\n```js\nimport mysql from 'mysql';\nimport { SqlCache } from 'apollo-server-cache-sql';\nimport responseCachePlugin from 'apollo-server-plugin-response-cache';\n\n// Setup the connection client\nconst connection = mysql.createConnection({\n  host: 'localhost',\n  user: 'me',\n  password: 'secret',\n  database: 'my_db',\n});\nconnection.connect();\n\n// Setup Apollo Server with SQL cache driver\nconst server = new ApolloServer({\n  // ...\n  plugins: [\n    responseCachePlugin({\n      cache: new SqlCache({\n        client: connection,\n        databaseName: 'my_db',\n        tableName: 'cache',\n      }),\n    }),\n  ],\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatissjanis%2Fapollo-server-cache-sql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatissjanis%2Fapollo-server-cache-sql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatissjanis%2Fapollo-server-cache-sql/lists"}