Skip to content

Commit bc8c61f

Browse files
committed
Merge branch 'main' into devin/1773717246-export-use-migrate-client
2 parents 62a26c6 + c18ef8e commit bc8c61f

119 files changed

Lines changed: 8474 additions & 3010 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AGENTS.md

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,83 @@ This guide helps AI agents quickly navigate the Constructive monorepo. Construct
6262
- Generate types/SDK: `cnc codegen`
6363
- Export schema SDL: `cnc get-graphql-schema`
6464

65+
## Best Practices
66+
67+
### Environment Configuration
68+
69+
Always use the unified environment configuration system — never read `process.env` directly for config values.
70+
71+
- **PGPM packages** (`pgpm/*`): `import { getEnvOptions } from '@pgpmjs/env'`
72+
- **GraphQL/Constructive packages** (`graphql/*`, `packages/cli`): `import { getEnvOptions } from '@constructive-io/graphql-env'`
73+
- **PostgreSQL tools** (`postgres/*`): `import { getPgEnvOptions } from 'pg-env'` or `@pgpmjs/env`
74+
75+
The system provides typed defaults, config file discovery (`pgpm.json`), env var parsing, and a clean merge hierarchy: **defaults → config file → env vars → runtime overrides**.
76+
77+
```typescript
78+
// GOOD
79+
import { getEnvOptions } from '@pgpmjs/env';
80+
const opts = getEnvOptions({ pg: { database: 'mydb' } });
81+
82+
// BAD — scattered, untyped, no defaults
83+
const host = process.env.PGHOST || 'localhost';
84+
const port = parseInt(process.env.PGPORT || '5432');
85+
```
86+
87+
### Testing
88+
89+
Constructive provides a layered testing framework stack. **Always use the appropriate framework** — never manually create `pg.Pool` or `pg.Client` instances in tests.
90+
91+
#### Which Framework to Use
92+
93+
| Scenario | Framework | Import |
94+
|----------|-----------|--------|
95+
| Raw SQL, RLS policies, database functions | `pgsql-test` | `import { getConnections } from 'pgsql-test'` |
96+
| PostGraphile schema, basic GraphQL queries | `graphile-test` | `import { getConnections } from 'graphile-test'` |
97+
| GraphQL with Constructive plugins (search, pgvector, etc.) | `@constructive-io/graphql-test` | `import { getConnections } from '@constructive-io/graphql-test'` |
98+
| HTTP endpoints, auth headers, middleware | `@constructive-io/graphql-server-test` | `import { getConnections } from '@constructive-io/graphql-server-test'` |
99+
100+
Each layer builds on `pgsql-test` underneath — they all create isolated test databases with proper teardown.
101+
102+
#### Required Test Hooks
103+
104+
Always include `beforeEach`/`afterEach` hooks to ensure test isolation via savepoints:
105+
106+
```typescript
107+
import { getConnections, PgTestClient } from 'pgsql-test';
108+
109+
let pg: PgTestClient;
110+
let db: PgTestClient;
111+
let teardown: () => Promise<void>;
112+
113+
beforeAll(async () => {
114+
({ pg, db, teardown } = await getConnections());
115+
});
116+
117+
afterAll(async () => {
118+
await teardown();
119+
});
120+
121+
beforeEach(async () => {
122+
await pg.beforeEach();
123+
await db.beforeEach();
124+
});
125+
126+
afterEach(async () => {
127+
await db.afterEach();
128+
await pg.afterEach();
129+
});
130+
```
131+
132+
#### Anti-Patterns to Avoid
133+
134+
- **Never** create `new pg.Pool()` or `new pg.Client()` in tests — use `getConnections()` from the appropriate framework
135+
- **Never** use `getPgPool()` from `pg-cache` in tests — that's for production connection pooling
136+
- **Never** manually create/drop databases in tests — `pgsql-test` handles this automatically
137+
- **Never** skip `beforeEach`/`afterEach` hooks — tests will leak state to each other
138+
- **Never** construct connection strings manually — use the env configuration system
139+
65140
## Tips
66141

67142
1. Start with `pgpm/core/AGENTS.md` to understand the migration and plan model.
68-
2. Use `packages/cli/AGENTS.md` to understand Constructives command routing.
143+
2. Use `packages/cli/AGENTS.md` to understand Constructive's command routing.
69144
3. Use `postgres/pgsql-test/AGENTS.md` for patterns around isolated test DBs and seeding.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pgpm install @pgpm/faker
4848
# 4. Deploy everything
4949
pgpm deploy --createdb --database mydb1
5050
psql -d mydb1 -c "SELECT faker.city('MI');"
51-
> Ann Arbor
51+
> Ann Arbor
5252
```
5353

5454
### Starting a New Project and Adding a Change

examples/codegen-integration/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.6.8](https://github.com/constructive-io/constructive/compare/@constructive-io/examples-codegen-integration@1.6.7...@constructive-io/examples-codegen-integration@1.6.8) (2026-03-17)
7+
8+
**Note:** Version bump only for package @constructive-io/examples-codegen-integration
9+
10+
## [1.6.7](https://github.com/constructive-io/constructive/compare/@constructive-io/examples-codegen-integration@1.6.6...@constructive-io/examples-codegen-integration@1.6.7) (2026-03-17)
11+
12+
**Note:** Version bump only for package @constructive-io/examples-codegen-integration
13+
614
## [1.6.6](https://github.com/constructive-io/constructive/compare/@constructive-io/examples-codegen-integration@1.6.5...@constructive-io/examples-codegen-integration@1.6.6) (2026-03-16)
715

816
**Note:** Version bump only for package @constructive-io/examples-codegen-integration

examples/codegen-integration/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@constructive-io/examples-codegen-integration",
3-
"version": "1.6.6",
3+
"version": "1.6.8",
44
"private": true,
55
"scripts": {
66
"codegen": "tsx scripts/codegen-runner.ts",

graphile/graphile-connection-filter/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.1.5](https://github.com/constructive-io/constructive/compare/graphile-connection-filter@1.1.4...graphile-connection-filter@1.1.5) (2026-03-17)
7+
8+
**Note:** Version bump only for package graphile-connection-filter
9+
10+
## [1.1.4](https://github.com/constructive-io/constructive/compare/graphile-connection-filter@1.1.3...graphile-connection-filter@1.1.4) (2026-03-17)
11+
12+
**Note:** Version bump only for package graphile-connection-filter
13+
614
## [1.1.3](https://github.com/constructive-io/constructive/compare/graphile-connection-filter@1.1.2...graphile-connection-filter@1.1.3) (2026-03-16)
715

816
**Note:** Version bump only for package graphile-connection-filter

graphile/graphile-connection-filter/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphile-connection-filter",
3-
"version": "1.1.3",
3+
"version": "1.1.5",
44
"description": "PostGraphile v5 native connection filter plugin - adds advanced filtering to connections",
55
"author": "Constructive <developers@constructive.io>",
66
"homepage": "https://github.com/constructive-io/constructive",

graphile/graphile-misc-plugins/CHANGELOG.md

Lines changed: 0 additions & 55 deletions
This file was deleted.

graphile/graphile-misc-plugins/README.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

graphile/graphile-misc-plugins/jest.config.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

graphile/graphile-misc-plugins/package.json

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)