Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 19 additions & 18 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,30 +21,31 @@ jobs:
constructive-tests:
runs-on: ubuntu-latest

# ALL TESTS DISABLED during v5 migration - will be re-enabled when v5 is ready to merge into main
# Tests being re-enabled as v5 migration progresses - remaining tests will be enabled when ready
strategy:
fail-fast: false
matrix:
include:
# - package: uploads/mime-bytes
# env: {}
# - package: pgpm/core
# env: {}
- package: pgpm/core
env: {}
# - package: pgpm/env
# env: {}
# - package: pgpm/cli
# env: {}
- package: pgpm/cli
env: {}
# - package: packages/cli
# env: {}

# - package: jobs/knative-job-service
# env: {}
# - package: packages/client
# env:
# TEST_DATABASE_URL: postgres://postgres:password@localhost:5432/postgres
# - package: postgres/pgsql-client
# env: {}
# - package: postgres/pgsql-test
# env: {}
- package: postgres/pgsql-client
env: {}
- package: postgres/pgsql-test
env: {}
# - package: packages/orm
# env: {}
# - package: packages/url-domains
Expand All @@ -57,10 +58,10 @@ jobs:
# env: {}
# - package: packages/query-builder
# env: {}
# - package: graphql/query
# env: {}
# - package: graphql/codegen
# env: {}
- package: graphql/query
env: {}
- package: graphql/codegen
env: {}
# - package: postgres/pg-ast
# env: {}
# - package: postgres/pg-codegen
Expand Down Expand Up @@ -99,10 +100,10 @@ jobs:
# env: {}
# - package: graphile/graphile-sql-expression-validator
# env: {}
# - package: graphql/server-test
# env: {}
# - package: graphql/env
# env: {}
- package: graphql/server-test
env: {}
- package: graphql/env
env: {}
- package: graphql/server
env: {}
# - package: graphql/test
Expand Down Expand Up @@ -185,7 +186,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
node-version: '22'

- name: Setup pnpm
uses: pnpm/action-setup@v2
Expand Down
62 changes: 45 additions & 17 deletions graphile/graphile-cache/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,98 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [2.0.0](https://github.com/constructive-io/constructive/compare/graphile-cache@1.8.0...graphile-cache@2.0.0) (2026-01-24)
## [1.4.7](https://github.com/launchql/launchql/compare/graphile-cache@1.4.6...graphile-cache@1.4.7) (2025-11-25)

**Note:** Version bump only for package graphile-cache

# [1.8.0](https://github.com/constructive-io/constructive/compare/graphile-cache@1.7.1...graphile-cache@1.8.0) (2026-01-20)
## [1.4.6](https://github.com/launchql/launchql/compare/graphile-cache@1.4.5...graphile-cache@1.4.6) (2025-11-25)

**Note:** Version bump only for package graphile-cache

## [1.7.1](https://github.com/constructive-io/constructive/compare/graphile-cache@1.7.0...graphile-cache@1.7.1) (2026-01-19)
## [1.4.5](https://github.com/launchql/launchql/compare/graphile-cache@1.4.4...graphile-cache@1.4.5) (2025-11-24)

**Note:** Version bump only for package graphile-cache

# [1.7.0](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.16...graphile-cache@1.7.0) (2026-01-18)
## [1.4.4](https://github.com/launchql/launchql/compare/graphile-cache@1.4.2...graphile-cache@1.4.4) (2025-11-22)

**Note:** Version bump only for package graphile-cache

## [1.6.16](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.15...graphile-cache@1.6.16) (2026-01-18)
## [1.4.3](https://github.com/launchql/launchql/compare/graphile-cache@1.4.2...graphile-cache@1.4.3) (2025-11-22)

**Note:** Version bump only for package graphile-cache

## [1.6.15](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.14...graphile-cache@1.6.15) (2026-01-09)
## [1.4.2](https://github.com/launchql/launchql/compare/graphile-cache@1.4.1...graphile-cache@1.4.2) (2025-11-20)

**Note:** Version bump only for package graphile-cache

## [1.6.14](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.13...graphile-cache@1.6.14) (2026-01-02)
## [1.4.1](https://github.com/launchql/launchql/compare/graphile-cache@1.4.0...graphile-cache@1.4.1) (2025-11-16)

**Note:** Version bump only for package graphile-cache

## [1.6.13](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.12...graphile-cache@1.6.13) (2026-01-02)
# [1.4.0](https://github.com/launchql/launchql/compare/graphile-cache@1.3.10...graphile-cache@1.4.0) (2025-11-16)

**Note:** Version bump only for package graphile-cache

## [1.6.12](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.11...graphile-cache@1.6.12) (2025-12-31)
## [1.3.10](https://github.com/launchql/launchql/compare/graphile-cache@1.3.9...graphile-cache@1.3.10) (2025-11-15)

### Bug Fixes

- stop pnpm install command from triggering every build ([ce88a6e](https://github.com/launchql/launchql/commit/ce88a6ece261ef02201d417bf3a9446a69df6618))

## [1.3.9](https://github.com/launchql/launchql/compare/graphile-cache@1.3.8...graphile-cache@1.3.9) (2025-11-14)

**Note:** Version bump only for package graphile-cache

## [1.3.8](https://github.com/launchql/launchql/compare/graphile-cache@1.3.7...graphile-cache@1.3.8) (2025-11-14)

**Note:** Version bump only for package graphile-cache

## [1.3.7](https://github.com/launchql/launchql/compare/graphile-cache@1.3.6...graphile-cache@1.3.7) (2025-11-13)

**Note:** Version bump only for package graphile-cache

## [1.3.6](https://github.com/launchql/launchql/compare/graphile-cache@1.3.5...graphile-cache@1.3.6) (2025-11-12)

**Note:** Version bump only for package graphile-cache

## [1.3.5](https://github.com/launchql/launchql/compare/graphile-cache@1.3.4...graphile-cache@1.3.5) (2025-11-12)

### Bug Fixes

- add explicit tsconfig.json path to build:dev script ([309dba1](https://github.com/launchql/launchql/commit/309dba1abd2c461803ffe2015cf82d1d3b1e6ee7))

## [1.3.4](https://github.com/launchql/launchql/compare/graphile-cache@1.3.3...graphile-cache@1.3.4) (2025-11-07)

**Note:** Version bump only for package graphile-cache

## [1.6.11](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.10...graphile-cache@1.6.11) (2025-12-27)
## [1.3.3](https://github.com/launchql/launchql/compare/graphile-cache@1.3.2...graphile-cache@1.3.3) (2025-11-07)

**Note:** Version bump only for package graphile-cache

## [1.6.10](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.9...graphile-cache@1.6.10) (2025-12-26)
## [1.3.2](https://github.com/launchql/launchql/compare/graphile-cache@1.3.1...graphile-cache@1.3.2) (2025-11-07)

**Note:** Version bump only for package graphile-cache

## [1.6.9](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.8...graphile-cache@1.6.9) (2025-12-24)
## [1.3.1](https://github.com/launchql/launchql/compare/graphile-cache@1.3.0...graphile-cache@1.3.1) (2025-10-18)

**Note:** Version bump only for package graphile-cache

## [1.6.8](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.7...graphile-cache@1.6.8) (2025-12-22)
# [1.3.0](https://github.com/launchql/launchql/compare/graphile-cache@1.2.0...graphile-cache@1.3.0) (2025-10-04)

**Note:** Version bump only for package graphile-cache

## [1.6.7](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.6...graphile-cache@1.6.7) (2025-12-21)
# [1.2.0](https://github.com/launchql/launchql/compare/graphile-cache@1.1.1...graphile-cache@1.2.0) (2025-09-17)

**Note:** Version bump only for package graphile-cache

## [1.6.6](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.5...graphile-cache@1.6.6) (2025-12-19)
## [1.1.1](https://github.com/launchql/launchql/compare/graphile-cache@1.1.0...graphile-cache@1.1.1) (2025-08-08)

**Note:** Version bump only for package graphile-cache

## [1.6.5](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.4...graphile-cache@1.6.5) (2025-12-18)
# [1.1.0](https://github.com/launchql/launchql/compare/graphile-cache@1.0.1...graphile-cache@1.1.0) (2025-07-31)

**Note:** Version bump only for package graphile-cache

## [1.6.4](https://github.com/constructive-io/constructive/compare/graphile-cache@1.6.3...graphile-cache@1.6.4) (2025-12-17)
## 1.0.1 (2025-06-28)

**Note:** Version bump only for package graphile-cache
49 changes: 24 additions & 25 deletions graphile/graphile-cache/README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,56 @@
# graphile-cache

<p align="center" width="100%">
<img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
<img height="250" src="https://raw.githubusercontent.com/launchql/launchql/refs/heads/main/assets/outline-logo.svg" />
</p>

<p align="center" width="100%">
<a href="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml">
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE">
<img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
</a>
<a href="https://www.npmjs.com/package/graphile-cache">
<img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=graphile%2Fgraphile-cache%2Fpackage.json"/>
<a href="https://github.com/launchql/launchql/actions/workflows/run-tests.yaml">
<img height="20" src="https://github.com/launchql/launchql/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/launchql/launchql/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
<a href="https://www.npmjs.com/package/graphile-cache"><img height="20" src="https://img.shields.io/github/package-json/v/launchql/launchql?filename=packages%2Fgraphile-cache%2Fpackage.json"/></a>
</p>

**`graphile-cache`** is an LRU cache for PostGraphile handlers with automatic cleanup when PostgreSQL pools are disposed.

> This package integrates with `pg-cache` for PostgreSQL pool management.
PostGraphile instance LRU cache with automatic cleanup when PostgreSQL pools are disposed.

## 🚀 Installation
## Installation

```bash
npm install graphile-cache pg-cache
```

## ✨ Features
Note: This package depends on `pg-cache` for the PostgreSQL pool management.

## Features

- LRU cache for PostGraphile instances
- Automatic cleanup when associated PostgreSQL pools are disposed
- Integrates seamlessly with `pg-cache`
- Service cache re-exported for convenience
- TypeScript support

## 🧠 How It Works
## How It Works

When you import this package, it automatically registers a cleanup callback with `pg-cache`. When a PostgreSQL pool is disposed, any PostGraphile instances using that pool are automatically removed from the cache.

## 📦 Usage
## Usage

### Basic caching flow
### Basic Usage

```typescript
import { graphileCache, GraphileCache } from 'graphile-cache';
import { getPgPool } from 'pg-cache';
import { postgraphile } from 'postgraphile';

// Create a PostGraphile instance
const pgPool = getPgPool({ database: 'mydb' });
const handler = postgraphile(pgPool, 'public', {
// PostGraphile options
});

// Cache it
const cacheEntry: GraphileCache = {
pgPool,
pgPoolKey: 'mydb',
Expand All @@ -67,7 +66,7 @@ if (cached) {
}
```

### Automatic cleanup
### Automatic Cleanup

The cleanup happens automatically:

Expand All @@ -87,7 +86,7 @@ console.log(graphileCache.has('mydb.public')); // false
console.log(graphileCache.has('mydb.private')); // false
```

### Complete example with Express
### Complete Example

```typescript
import { graphileCache, GraphileCache } from 'graphile-cache';
Expand All @@ -96,27 +95,27 @@ import { postgraphile } from 'postgraphile';

function getGraphileInstance(database: string, schema: string): GraphileCache {
const key = `${database}.${schema}`;

// Check cache first
const cached = graphileCache.get(key);
if (cached) {
return cached;
}

// Create new instance
const pgPool = getPgPool({ database });
const handler = postgraphile(pgPool, schema, {
graphqlRoute: '/graphql',
graphiqlRoute: '/graphiql',
// other options...
});

const entry: GraphileCache = {
pgPool,
pgPoolKey: database,
handler
};

// Cache it
graphileCache.set(key, entry);
return entry;
Expand All @@ -134,14 +133,14 @@ app.use((req, res, next) => {
```typescript
import { closeAllCaches } from 'graphile-cache';

// This closes all caches including pg pools
process.on('SIGTERM', async () => {
// Closes all caches including pg pools
await closeAllCaches();
process.exit(0);
});
```

## 📘 API Reference
## API Reference

### graphileCache

Expand Down Expand Up @@ -171,7 +170,7 @@ Closes all caches including the service cache, graphile cache, and all PostgreSQ

Re-exported from `pg-cache` for convenience.

## 🔌 Integration Details
## Integration Details

The integration with `pg-cache` happens automatically when this module is imported. The cleanup callback is registered immediately, ensuring that PostGraphile instances are cleaned up whenever their associated PostgreSQL pools are disposed.

Expand Down
Loading