Skip to content

Commit eaf4021

Browse files
authored
Merge pull request #372 from launchql/regulate-readme-graphile
Regulate readme graphile
2 parents 658faf2 + 7cb376e commit eaf4021

13 files changed

Lines changed: 252 additions & 129 deletions

File tree

graphile/graphile-cache/README.md

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,42 @@
1616
</a>
1717
</p>
1818

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

21-
## Installation
21+
> This package integrates with `pg-cache` for PostgreSQL pool management.
22+
23+
## 🚀 Installation
2224

2325
```bash
2426
npm install graphile-cache pg-cache
2527
```
2628

27-
Note: This package depends on `pg-cache` for the PostgreSQL pool management.
28-
29-
## Features
29+
## ✨ Features
3030

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

37-
## How It Works
37+
## 🧠 How It Works
3838

3939
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.
4040

41-
## Usage
41+
## 📦 Usage
4242

43-
### Basic Usage
43+
### Basic caching flow
4444

4545
```typescript
4646
import { graphileCache, GraphileCache } from 'graphile-cache';
4747
import { getPgPool } from 'pg-cache';
4848
import { postgraphile } from 'postgraphile';
4949

50-
// Create a PostGraphile instance
5150
const pgPool = getPgPool({ database: 'mydb' });
5251
const handler = postgraphile(pgPool, 'public', {
5352
// PostGraphile options
5453
});
5554

56-
// Cache it
5755
const cacheEntry: GraphileCache = {
5856
pgPool,
5957
pgPoolKey: 'mydb',
@@ -69,7 +67,7 @@ if (cached) {
6967
}
7068
```
7169

72-
### Automatic Cleanup
70+
### Automatic cleanup when pools disappear
7371

7472
The cleanup happens automatically:
7573

@@ -89,7 +87,7 @@ console.log(graphileCache.has('mydb.public')); // false
8987
console.log(graphileCache.has('mydb.private')); // false
9088
```
9189

92-
### Complete Example
90+
### Complete example with Express
9391

9492
```typescript
9593
import { graphileCache, GraphileCache } from 'graphile-cache';
@@ -136,14 +134,14 @@ app.use((req, res, next) => {
136134
```typescript
137135
import { closeAllCaches } from 'graphile-cache';
138136

139-
// This closes all caches including pg pools
140137
process.on('SIGTERM', async () => {
138+
// Closes all caches including pg pools
141139
await closeAllCaches();
142140
process.exit(0);
143141
});
144142
```
145143

146-
## API Reference
144+
## 📘 API Reference
147145

148146
### graphileCache
149147

@@ -173,7 +171,7 @@ Closes all caches including the service cache, graphile cache, and all PostgreSQ
173171

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

176-
## Integration Details
174+
## 🔌 Integration Details
177175

178176
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.
179177

graphile/graphile-i18n/README.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,22 @@
1616
</a>
1717
</p>
1818

19-
TypeScript rewrite of the Graphile/PostGraphile i18n plugin. Adds language-aware fields sourced from translation tables declared via smart comments.
19+
**`graphile-i18n`** is a TypeScript rewrite of the Graphile/PostGraphile i18n plugin. It adds language-aware fields sourced from translation tables declared via smart comments and respects `Accept-Language` with sensible fallbacks.
2020

21-
## Install
21+
## 🚀 Installation
2222

2323
```bash
2424
pnpm add graphile-i18n
2525
```
2626

27-
## Usage
27+
## ✨ Features
28+
29+
- Smart comments (`@i18n`) to wire translation tables
30+
- `Accept-Language` detection with graceful fallback to base values
31+
- Works with PostGraphile context via `additionalGraphQLContextFromRequest`
32+
- TypeScript-first implementation
33+
34+
## 📦 Usage
2835

2936
1. Add a translation table and tag the base table with `@i18n`:
3037

@@ -70,12 +77,18 @@ app.use(
7077

7178
Requests with `Accept-Language` headers receive the closest translation; fields fall back to the base table values when a translation is missing.
7279

73-
## Tests
80+
## 🧰 Configuration Options
7481

75-
Tests run against a real Postgres instance using `graphile-test`:
82+
All options are provided through `graphileBuildOptions`:
7683

77-
```bash
78-
pnpm test
79-
```
84+
- `langPluginLanguageCodeColumn` — translation table column name, default `lang_code`
85+
- `langPluginLanguageCodeGqlField` — exposed GraphQL field name, default `langCode`
86+
- `langPluginAllowedTypes` — allowed base column types for translation, default `['citext', 'text']`
87+
- `langPluginDefaultLanguages` — fallback language order, default `['en']`
88+
89+
## 🧪 Testing
8090

81-
Ensure Postgres is available at `postgres://postgres:password@localhost:5432`.
91+
```sh
92+
# requires a local Postgres available (defaults to postgres/password@localhost:5432)
93+
pnpm --filter graphile-i18n test
94+
```

graphile/graphile-meta-schema/README.md

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,41 @@
1616
</a>
1717
</p>
1818

19-
## Install
19+
**`graphile-meta-schema`** exposes a `_meta` GraphQL schema so you can introspect tables, fields, and constraints directly from PostGraphile.
20+
21+
## 🚀 Installation
2022

2123
```sh
2224
pnpm add graphile-meta-schema
2325
```
2426

25-
## Example Query
27+
## ✨ Features
28+
29+
- GraphQL meta endpoint for table/field/constraint details
30+
- Works alongside your existing PostGraphile schemas
31+
- Ships with fixtures to explore constraint metadata
32+
33+
## 📦 Usage
34+
35+
Register the plugin with PostGraphile (CLI or library):
36+
37+
```ts
38+
import express from 'express';
39+
import { postgraphile } from 'postgraphile';
40+
import PgMetaschemaPlugin from 'graphile-meta-schema';
41+
42+
const app = express();
43+
44+
app.use(
45+
postgraphile(process.env.DATABASE_URL, ['app_public'], {
46+
appendPlugins: [PgMetaschemaPlugin]
47+
})
48+
);
49+
```
50+
51+
The plugin adds a `_meta` query root alongside your existing schemas. Use it to inspect fields, constraints, relations, and generated inflection.
52+
53+
### Example Query
2654

2755
```gql
2856
query MetaQuery {
@@ -88,17 +116,9 @@ query MetaQuery {
88116
}
89117
```
90118

91-
## Testing
119+
## 🧪 Testing
92120

93121
```sh
94122
# requires a local Postgres with PostGIS available (defaults to postgres/password@localhost:5432)
95123
pnpm --filter graphile-meta-schema test
96-
```
97-
98-
If you want to explore the fixtures manually:
99-
100-
```sh
101-
createdb metaschema_example
102-
psql metaschema_example < sql/test.sql
103-
psql metaschema_example < sql/types.sql
104-
```
124+
```

graphile/graphile-pg-type-mappings/README.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,22 @@
1616
</a>
1717
</p>
1818

19-
Custom PostgreSQL type mappings plugin for Graphile/PostGraphile.
19+
**`graphile-pg-type-mappings`** is a Graphile/PostGraphile plugin that maps custom PostgreSQL types to GraphQL scalars.
2020

21-
This plugin provides custom type mappings for PostgreSQL types to GraphQL types, including:
21+
## 🚀 Installation
22+
23+
```bash
24+
npm install graphile-pg-type-mappings
25+
```
26+
27+
## ✨ Features
28+
29+
- Sensible defaults for common custom Postgres types (`email`, `origin`, `multiple_select`, etc.)
30+
- Override or extend mappings via `customTypeMappings`
31+
- Works with PostGraphile v4 as a standard plugin
32+
- TypeScript definitions for mapping configuration
33+
34+
### Default mappings
2235

2336
- `email``String`
2437
- `hostname``String`
@@ -29,13 +42,7 @@ This plugin provides custom type mappings for PostgreSQL types to GraphQL types,
2942

3043
> **Note:** If you need PostGIS types (like `geolocation` or `geopolygon``GeoJSON`), you can add them via `customTypeMappings` when using the PostGIS plugin.
3144
32-
## Installation
33-
34-
```bash
35-
npm install graphile-pg-type-mappings
36-
```
37-
38-
## Usage
45+
## 📦 Usage
3946

4047
### Basic Usage (Default Mappings)
4148

@@ -132,7 +139,7 @@ const postgraphileOptions = {
132139
};
133140
```
134141

135-
## API
142+
## 📘 API
136143

137144
### `CustomPgTypeMappingsPlugin`
138145

@@ -155,3 +162,10 @@ interface CustomPgTypeMappingsPluginOptions {
155162
customTypeMappings?: TypeMapping[];
156163
}
157164
```
165+
166+
## 🧪 Testing
167+
168+
```sh
169+
# requires a local Postgres available (defaults to postgres/password@localhost:5432)
170+
pnpm --filter graphile-pg-type-mappings test
171+
```

graphile/graphile-plugin-connection-filter-postgis/README.md

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,44 @@
1616
</a>
1717
</p>
1818

19-
This plugin exposes additional PostGIS-related fields on the `filter` argument of Connections.
19+
**`graphile-plugin-connection-filter-postgis`** exposes PostGIS-aware operators on the `filter` argument for PostGraphile connections.
2020

21-
## Usage
21+
## 🚀 Installation
22+
23+
```bash
24+
npm install graphile-plugin-connection-filter-postgis
25+
```
26+
27+
## ✨ Features
28+
29+
- Adds PostGIS functions and operators to `graphile-plugin-connection-filter`
30+
- Supports both `geometry` and `geography` columns
31+
- Works with PostGraphile v4 filter inputs
32+
33+
## 📦 Usage
2234

2335
Requires `postgraphile@^4.5.0` and the following plugins appended prior to this plugin:
2436

2537
- `@graphile/postgis@0.1.0`
2638
- `graphile-plugin-connection-filter@^2.0.0`
2739

28-
## Operators
40+
```ts
41+
import PostGISFilterPlugin from 'graphile-plugin-connection-filter-postgis';
42+
import PostGISPlugin from '@graphile/postgis';
43+
import ConnectionFilterPlugin from 'graphile-plugin-connection-filter';
44+
45+
app.use(
46+
postgraphile(pgConfig, schemas, {
47+
appendPlugins: [
48+
PostGISPlugin,
49+
ConnectionFilterPlugin,
50+
PostGISFilterPlugin
51+
]
52+
})
53+
);
54+
```
55+
56+
## 🔎 Operators
2957

3058
| PostGIS function | Types | GraphQL field name |
3159
| --- | --- | --- |
@@ -59,13 +87,11 @@ Requires `postgraphile@^4.5.0` and the following plugins appended prior to this
5987
| ~ | geometry | bboxContains |
6088
| ~= | geometry | bboxEquals |
6189

62-
## Development
90+
## 🧑‍💻 Development
6391

64-
To establish a test environment, create an empty PostgreSQL database and set a `TEST_DATABASE_URL` environment variable with your database connection string.
92+
## 🧪 Testing
6593

66-
```bash
67-
createdb graphile_test
68-
export TEST_DATABASE_URL=postgres://localhost:5432/graphile_test
69-
yarn
70-
yarn test
94+
```sh
95+
# requires a local Postgres with PostGIS available (defaults to postgres/password@localhost:5432)
96+
pnpm --filter graphile-plugin-connection-filter-postgis test
7197
```

0 commit comments

Comments
 (0)