Skip to content

Commit dd32eed

Browse files
authored
Merge pull request #59 from constructive-io/devin/1773817552-schema-config-refactor
refactor: update schema export docs from flat props to nested `schema` object
2 parents d76e358 + a31c704 commit dd32eed

4 files changed

Lines changed: 31 additions & 37 deletions

File tree

42.1 KB
Binary file not shown.

skills/constructive-graphql-codegen/SKILL.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,7 @@ import { generate } from '@constructive-io/graphql-codegen';
139139
// Export from database
140140
await generate({
141141
db: { schemas: ['public'] },
142-
schemaOnly: true,
143-
schemaOnlyOutput: './schemas',
144-
schemaOnlyFilename: 'public.graphql',
142+
schema: { enabled: true, output: './schemas', filename: 'public.graphql' },
145143
});
146144

147145
// Export from PGPM module
@@ -150,16 +148,13 @@ await generate({
150148
pgpm: { modulePath: './packages/my-module' },
151149
schemas: ['app_public'],
152150
},
153-
schemaOnly: true,
154-
schemaOnlyOutput: './schemas',
155-
schemaOnlyFilename: 'app_public.graphql',
151+
schema: { enabled: true, output: './schemas', filename: 'app_public.graphql' },
156152
});
157153

158154
// Export from endpoint
159155
await generate({
160156
endpoint: 'https://api.example.com/graphql',
161-
schemaOnly: true,
162-
schemaOnlyOutput: './schemas',
157+
schema: { enabled: true, output: './schemas' },
163158
});
164159
```
165160

@@ -232,9 +227,11 @@ interface GenerateOptions {
232227
cli?: CliConfig | boolean; // Default: false
233228

234229
// Schema export (instead of code generation)
235-
schemaOnly?: boolean;
236-
schemaOnlyOutput?: string;
237-
schemaOnlyFilename?: string; // Default: 'schema.graphql'
230+
schema?: {
231+
enabled?: boolean; // Enable schema export mode
232+
output?: string; // Output directory (default: same as output)
233+
filename?: string; // Default: 'schema.graphql'
234+
};
238235

239236
// Documentation (generated alongside code)
240237
docs?: DocsConfig | boolean; // Default: { readme: true, agents: true, mcp: false, skills: false }

skills/constructive-graphql-codegen/references/cli-reference.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ npx @constructive-io/graphql-codegen generate [options]
3434
| `--output <dir>` | `-o` | Output directory | `./generated/graphql` |
3535
| `--target <name>` | `-t` | Target name (for multi-target configs) | - |
3636

37+
### Schema Export Options
38+
39+
| Option | Description | Default |
40+
|--------|-------------|---------|
41+
| `--schema-enabled` | Export GraphQL SDL schema file | `false` |
42+
| `--schema-output <dir>` | Output directory for exported schema | Same as `--output` |
43+
| `--schema-filename <name>` | Filename for exported schema | `schema.graphql` |
44+
3745
### Other Options
3846

3947
| Option | Alias | Description | Default |

skills/constructive-graphql-codegen/references/generate-schemas.md

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Export GraphQL schemas to `.graphql` SDL files without generating any code. This is useful for creating portable, version-controllable schema artifacts that can then be used as input for code generation via `schemaFile` or `schemaDir`.
44

5+
Schema export uses a nested `schema` config object: `schema: { enabled, output, filename }`.
6+
57
## When to Use
68

79
- You want deterministic, portable builds that don't depend on a live database or endpoint at code generation time
@@ -17,9 +19,7 @@ import { generate } from '@constructive-io/graphql-codegen';
1719
// Export from database
1820
await generate({
1921
db: { schemas: ['public'] },
20-
schemaOnly: true,
21-
schemaOnlyOutput: './schemas',
22-
schemaOnlyFilename: 'public.graphql',
22+
schema: { enabled: true, output: './schemas', filename: 'public.graphql' },
2323
});
2424

2525
// Export from PGPM module
@@ -28,16 +28,13 @@ await generate({
2828
pgpm: { modulePath: './packages/my-module' },
2929
schemas: ['app_public'],
3030
},
31-
schemaOnly: true,
32-
schemaOnlyOutput: './schemas',
33-
schemaOnlyFilename: 'app_public.graphql',
31+
schema: { enabled: true, output: './schemas', filename: 'app_public.graphql' },
3432
});
3533

3634
// Export from endpoint
3735
await generate({
3836
endpoint: 'https://api.example.com/graphql',
39-
schemaOnly: true,
40-
schemaOnlyOutput: './schemas',
37+
schema: { enabled: true, output: './schemas' },
4138
});
4239

4340
// Export from PGPM workspace + module name
@@ -49,21 +46,19 @@ await generate({
4946
},
5047
schemas: ['app_public'],
5148
},
52-
schemaOnly: true,
53-
schemaOnlyOutput: './schemas',
54-
schemaOnlyFilename: 'app_public.graphql',
49+
schema: { enabled: true, output: './schemas', filename: 'app_public.graphql' },
5550
});
5651
```
5752

5853
## Options
5954

6055
| Option | Type | Default | Description |
6156
|--------|------|---------|-------------|
62-
| `schemaOnly` | `boolean` | `false` | Enable schema export mode (no code generation) |
63-
| `schemaOnlyOutput` | `string` | Same as `output` | Output directory for the exported schema file |
64-
| `schemaOnlyFilename` | `string` | `'schema.graphql'` | Filename for the exported schema |
57+
| `schema.enabled` | `boolean` | `false` | Enable schema export mode |
58+
| `schema.output` | `string` | Same as `output` | Output directory for the exported schema file |
59+
| `schema.filename` | `string` | `'schema.graphql'` | Filename for the exported schema |
6560

66-
When `schemaOnly: true`, no generators run (`reactQuery`, `orm`, `cli` are all ignored). The function fetches the schema via introspection, converts it to SDL using `printSchema()`, and writes it to disk.
61+
When `schema.enabled` is `true` and no generators are enabled (`reactQuery`, `orm`, `cli` are all false), the function fetches the schema via introspection, converts it to SDL using `printSchema()`, and writes it to disk. When generators are also enabled, the schema is exported alongside code generation.
6762

6863
## Recommended Two-Step Workflow
6964

@@ -76,16 +71,12 @@ import { generate } from '@constructive-io/graphql-codegen';
7671
// Export each schema you need
7772
await generate({
7873
db: { schemas: ['public'] },
79-
schemaOnly: true,
80-
schemaOnlyOutput: './schemas',
81-
schemaOnlyFilename: 'public.graphql',
74+
schema: { enabled: true, output: './schemas', filename: 'public.graphql' },
8275
});
8376

8477
await generate({
8578
db: { schemas: ['admin'] },
86-
schemaOnly: true,
87-
schemaOnlyOutput: './schemas',
88-
schemaOnlyFilename: 'admin.graphql',
79+
schema: { enabled: true, output: './schemas', filename: 'admin.graphql' },
8980
});
9081
```
9182

@@ -113,7 +104,7 @@ await generate({
113104

114105
## Multi-Target Schema Export
115106

116-
When using `generateMulti()` with `schemaOnly: true`, each target's schema is exported with the target name as the filename:
107+
When using `generateMulti()` with `schema: { enabled: true }`, each target's schema is exported with the target name as the filename:
117108

118109
```typescript
119110
import { generateMulti } from '@constructive-io/graphql-codegen';
@@ -129,7 +120,7 @@ await generateMulti({
129120
output: './schemas',
130121
},
131122
},
132-
schemaOnly: true,
123+
schema: { enabled: true },
133124
});
134125
// Produces: schemas/public.graphql, schemas/admin.graphql
135126
```
@@ -139,9 +130,7 @@ await generateMulti({
139130
```typescript
140131
const result = await generate({
141132
db: { schemas: ['public'] },
142-
schemaOnly: true,
143-
schemaOnlyOutput: './schemas',
144-
schemaOnlyFilename: 'public.graphql',
133+
schema: { enabled: true, output: './schemas', filename: 'public.graphql' },
145134
});
146135

147136
if (result.success) {

0 commit comments

Comments
 (0)