@stonecrop/schema 0.8.12 → 0.8.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -200,6 +200,90 @@ try {
|
|
|
200
200
|
}
|
|
201
201
|
```
|
|
202
202
|
|
|
203
|
+
## GraphQL to Doctype CLI
|
|
204
|
+
|
|
205
|
+
The `stonecrop-schema generate` command converts a GraphQL schema into Stonecrop doctype JSON files.
|
|
206
|
+
|
|
207
|
+
### Basic usage
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
# From a live GraphQL endpoint
|
|
211
|
+
stonecrop-schema generate -e http://localhost:3000/graphql -o ./app/doctypes
|
|
212
|
+
|
|
213
|
+
# From a saved introspection JSON file
|
|
214
|
+
stonecrop-schema generate -i introspection.json -o ./app/doctypes
|
|
215
|
+
|
|
216
|
+
# From an SDL file
|
|
217
|
+
stonecrop-schema generate -s schema.graphql -o ./app/doctypes
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### Filtering types
|
|
221
|
+
|
|
222
|
+
GraphQL schemas (especially PostGraphile) expose many internal types. Use `--include` to
|
|
223
|
+
allowlist exactly the types you need, rather than having to `--exclude` everything you don't:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# Only generate doctypes for these three types
|
|
227
|
+
stonecrop-schema generate -e http://localhost:3000/graphql -o ./app/doctypes \
|
|
228
|
+
--include 'SalesOrder,Customer,Item'
|
|
229
|
+
|
|
230
|
+
# Alternatively, exclude specific types
|
|
231
|
+
stonecrop-schema generate -e http://localhost:3000/graphql -o ./app/doctypes \
|
|
232
|
+
--exclude 'PageInfo,StonecropActionDefinition'
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
`--include` and `--exclude` can be combined: `--include` is applied first (narrowing the set),
|
|
236
|
+
then `--exclude` removes any remaining unwanted names.
|
|
237
|
+
|
|
238
|
+
### All options
|
|
239
|
+
|
|
240
|
+
| Flag | Short | Description |
|
|
241
|
+
|------|-------|-------------|
|
|
242
|
+
| `--endpoint <url>` | `-e` | Fetch introspection from a live GraphQL endpoint |
|
|
243
|
+
| `--introspection <file>` | `-i` | Read from a saved introspection JSON file |
|
|
244
|
+
| `--sdl <file>` | `-s` | Read from a GraphQL SDL (`.graphql`) file |
|
|
245
|
+
| `--output <dir>` | `-o` | Directory to write doctype JSON files (required) |
|
|
246
|
+
| `--include <types>` | | Comma-separated allowlist of type names to generate |
|
|
247
|
+
| `--exclude <types>` | | Comma-separated list of type names to skip |
|
|
248
|
+
| `--overrides <file>` | | JSON file with per-type, per-field overrides |
|
|
249
|
+
| `--custom-scalars <file>` | | JSON file mapping custom scalar names to field templates |
|
|
250
|
+
| `--include-unmapped` | | Retain `_graphqlType` metadata on fields with no mapping |
|
|
251
|
+
| `--help` | `-h` | Show help |
|
|
252
|
+
|
|
253
|
+
### Custom scalars
|
|
254
|
+
|
|
255
|
+
For servers that use non-standard scalars (e.g. PostGraphile's `BigFloat`, `Datetime`), provide
|
|
256
|
+
a JSON mapping file:
|
|
257
|
+
|
|
258
|
+
```json
|
|
259
|
+
{
|
|
260
|
+
"BigFloat": { "component": "ADecimalInput", "fieldtype": "Decimal" },
|
|
261
|
+
"Datetime": { "component": "ADatetimeInput", "fieldtype": "Datetime" }
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
stonecrop-schema generate -e http://localhost:3000/graphql -o ./app/doctypes \
|
|
267
|
+
--custom-scalars custom-scalars.json
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Per-field overrides
|
|
271
|
+
|
|
272
|
+
Override the generated field definition for specific types and fields:
|
|
273
|
+
|
|
274
|
+
```json
|
|
275
|
+
{
|
|
276
|
+
"SalesOrder": {
|
|
277
|
+
"totalAmount": { "fieldtype": "Currency", "component": "ACurrencyInput" }
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
stonecrop-schema generate -e http://localhost:3000/graphql -o ./app/doctypes \
|
|
284
|
+
--overrides overrides.json
|
|
285
|
+
```
|
|
286
|
+
|
|
203
287
|
## DDL Conversion
|
|
204
288
|
|
|
205
289
|
Convert PostgreSQL DDL statements to Stonecrop doctype schemas:
|