![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
apollo-server-cache-sql
Advanced tools
Minimalistic Apollo Server SQL Cache driver for times when Redis or other more modern caching solutions are too expensive or unavailable.
npm install --save-dev apollo-server-cache-sql
# or
yarn add -D apollo-server-cache-sql
A SQL table for cache artifact storage must be created. The following is a blueprint for a basic caching table.
CREATE TABLE `cache` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`key` varchar(255) DEFAULT NULL,
`value` longtext,
`ttl` int(11) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
UNIQUE KEY `key` (`key`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
import mysql from 'mysql';
import { SqlCache } from 'apollo-server-cache-sql';
// Setup the connection client
const connection = mysql.createConnection({
host: 'localhost',
user: 'me',
password: 'secret',
database: 'my_db',
});
connection.connect();
// Setup Apollo Server with SQL cache driver
const server = new ApolloServer({
typeDefs,
resolvers,
cache: new SqlCache({
client: connection,
databaseName: 'my_db',
tableName: 'cache',
}),
dataSources: () => ({
moviesAPI: new MoviesAPI(),
}),
});
import mysql from 'mysql';
import { SqlCache } from 'apollo-server-cache-sql';
import responseCachePlugin from 'apollo-server-plugin-response-cache';
// Setup the connection client
const connection = mysql.createConnection({
host: 'localhost',
user: 'me',
password: 'secret',
database: 'my_db',
});
connection.connect();
// Setup Apollo Server with SQL cache driver
const server = new ApolloServer({
// ...
plugins: [
responseCachePlugin({
cache: new SqlCache({
client: connection,
databaseName: 'my_db',
tableName: 'cache',
}),
}),
],
});
FAQs
Minimalistic Apollo Server SQL Cache driver
The npm package apollo-server-cache-sql receives a total of 2 weekly downloads. As such, apollo-server-cache-sql popularity was classified as not popular.
We found that apollo-server-cache-sql demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.