@constructive-io/graphql-codegen 2.19.0 → 2.20.0
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 +1818 -113
- package/__tests__/codegen/input-types-generator.test.d.ts +1 -0
- package/__tests__/codegen/input-types-generator.test.js +635 -0
- package/cli/codegen/barrel.d.ts +27 -0
- package/cli/codegen/barrel.js +163 -0
- package/cli/codegen/client.d.ts +4 -0
- package/cli/codegen/client.js +170 -0
- package/cli/codegen/custom-mutations.d.ts +38 -0
- package/cli/codegen/custom-mutations.js +149 -0
- package/cli/codegen/custom-queries.d.ts +38 -0
- package/cli/codegen/custom-queries.js +358 -0
- package/cli/codegen/filters.d.ts +27 -0
- package/cli/codegen/filters.js +357 -0
- package/cli/codegen/gql-ast.d.ts +41 -0
- package/cli/codegen/gql-ast.js +329 -0
- package/cli/codegen/index.d.ts +71 -0
- package/cli/codegen/index.js +147 -0
- package/cli/codegen/mutations.d.ts +30 -0
- package/cli/codegen/mutations.js +410 -0
- package/cli/codegen/orm/barrel.d.ts +18 -0
- package/cli/codegen/orm/barrel.js +48 -0
- package/cli/codegen/orm/client-generator.d.ts +45 -0
- package/cli/codegen/orm/client-generator.js +646 -0
- package/cli/codegen/orm/custom-ops-generator.d.ts +30 -0
- package/cli/codegen/orm/custom-ops-generator.js +350 -0
- package/cli/codegen/orm/index.d.ts +38 -0
- package/cli/codegen/orm/index.js +88 -0
- package/cli/codegen/orm/input-types-generator.d.ts +21 -0
- package/cli/codegen/orm/input-types-generator.js +705 -0
- package/cli/codegen/orm/input-types-generator.test.d.ts +1 -0
- package/cli/codegen/orm/input-types-generator.test.js +75 -0
- package/cli/codegen/orm/model-generator.d.ts +32 -0
- package/cli/codegen/orm/model-generator.js +264 -0
- package/cli/codegen/orm/query-builder.d.ts +161 -0
- package/cli/codegen/orm/query-builder.js +366 -0
- package/cli/codegen/orm/select-types.d.ts +169 -0
- package/cli/codegen/orm/select-types.js +16 -0
- package/cli/codegen/orm/select-types.test.d.ts +11 -0
- package/cli/codegen/orm/select-types.test.js +22 -0
- package/cli/codegen/queries.d.ts +25 -0
- package/cli/codegen/queries.js +438 -0
- package/cli/codegen/scalars.d.ts +12 -0
- package/cli/codegen/scalars.js +71 -0
- package/cli/codegen/schema-gql-ast.d.ts +51 -0
- package/cli/codegen/schema-gql-ast.js +385 -0
- package/cli/codegen/ts-ast.d.ts +122 -0
- package/cli/codegen/ts-ast.js +280 -0
- package/cli/codegen/type-resolver.d.ts +96 -0
- package/cli/codegen/type-resolver.js +246 -0
- package/cli/codegen/types.d.ts +12 -0
- package/cli/codegen/types.js +69 -0
- package/cli/codegen/utils.d.ts +163 -0
- package/cli/codegen/utils.js +326 -0
- package/cli/commands/generate-orm.d.ts +37 -0
- package/cli/commands/generate-orm.js +195 -0
- package/cli/commands/generate.d.ts +39 -0
- package/cli/commands/generate.js +299 -0
- package/cli/commands/index.d.ts +7 -0
- package/cli/commands/index.js +12 -0
- package/cli/commands/init.d.ts +35 -0
- package/cli/commands/init.js +176 -0
- package/cli/index.d.ts +4 -0
- package/cli/index.js +291 -0
- package/cli/introspect/fetch-meta.d.ts +31 -0
- package/cli/introspect/fetch-meta.js +108 -0
- package/cli/introspect/fetch-schema.d.ts +21 -0
- package/cli/introspect/fetch-schema.js +86 -0
- package/cli/introspect/index.d.ts +8 -0
- package/cli/introspect/index.js +16 -0
- package/cli/introspect/meta-query.d.ts +111 -0
- package/cli/introspect/meta-query.js +191 -0
- package/cli/introspect/schema-query.d.ts +20 -0
- package/cli/introspect/schema-query.js +123 -0
- package/cli/introspect/transform-schema.d.ts +74 -0
- package/cli/introspect/transform-schema.js +269 -0
- package/cli/introspect/transform-schema.test.d.ts +1 -0
- package/cli/introspect/transform-schema.test.js +67 -0
- package/cli/introspect/transform.d.ts +21 -0
- package/cli/introspect/transform.js +216 -0
- package/cli/watch/cache.d.ts +45 -0
- package/cli/watch/cache.js +111 -0
- package/cli/watch/debounce.d.ts +19 -0
- package/cli/watch/debounce.js +89 -0
- package/cli/watch/hash.d.ts +17 -0
- package/cli/watch/hash.js +48 -0
- package/cli/watch/index.d.ts +10 -0
- package/cli/watch/index.js +22 -0
- package/cli/watch/orchestrator.d.ts +63 -0
- package/cli/watch/orchestrator.js +228 -0
- package/cli/watch/poller.d.ts +65 -0
- package/cli/watch/poller.js +203 -0
- package/cli/watch/types.d.ts +67 -0
- package/cli/watch/types.js +5 -0
- package/client/error.d.ts +95 -0
- package/client/error.js +255 -0
- package/client/execute.d.ts +57 -0
- package/client/execute.js +124 -0
- package/client/index.d.ts +6 -0
- package/client/index.js +18 -0
- package/client/typed-document.d.ts +31 -0
- package/client/typed-document.js +44 -0
- package/core/ast.d.ts +10 -0
- package/core/ast.js +593 -0
- package/core/custom-ast.d.ts +35 -0
- package/core/custom-ast.js +204 -0
- package/core/index.d.ts +8 -0
- package/core/index.js +33 -0
- package/core/meta-object/convert.d.ts +65 -0
- package/core/meta-object/convert.js +63 -0
- package/core/meta-object/format.json +93 -0
- package/core/meta-object/index.d.ts +2 -0
- package/core/meta-object/index.js +18 -0
- package/core/meta-object/validate.d.ts +9 -0
- package/core/meta-object/validate.js +34 -0
- package/core/query-builder.d.ts +46 -0
- package/core/query-builder.js +412 -0
- package/core/types.d.ts +139 -0
- package/core/types.js +28 -0
- package/esm/__tests__/codegen/input-types-generator.test.d.ts +1 -0
- package/esm/__tests__/codegen/input-types-generator.test.js +633 -0
- package/esm/cli/codegen/barrel.d.ts +27 -0
- package/esm/cli/codegen/barrel.js +156 -0
- package/esm/cli/codegen/client.d.ts +4 -0
- package/esm/cli/codegen/client.js +167 -0
- package/esm/cli/codegen/custom-mutations.d.ts +38 -0
- package/esm/cli/codegen/custom-mutations.js +145 -0
- package/esm/cli/codegen/custom-queries.d.ts +38 -0
- package/esm/cli/codegen/custom-queries.js +354 -0
- package/esm/cli/codegen/filters.d.ts +27 -0
- package/esm/cli/codegen/filters.js +351 -0
- package/esm/cli/codegen/gql-ast.d.ts +41 -0
- package/esm/cli/codegen/gql-ast.js +288 -0
- package/esm/cli/codegen/index.d.ts +71 -0
- package/esm/cli/codegen/index.js +124 -0
- package/esm/cli/codegen/mutations.d.ts +30 -0
- package/esm/cli/codegen/mutations.js +404 -0
- package/esm/cli/codegen/orm/barrel.d.ts +18 -0
- package/esm/cli/codegen/orm/barrel.js +44 -0
- package/esm/cli/codegen/orm/client-generator.d.ts +45 -0
- package/esm/cli/codegen/orm/client-generator.js +640 -0
- package/esm/cli/codegen/orm/custom-ops-generator.d.ts +30 -0
- package/esm/cli/codegen/orm/custom-ops-generator.js +346 -0
- package/esm/cli/codegen/orm/index.d.ts +38 -0
- package/esm/cli/codegen/orm/index.js +75 -0
- package/esm/cli/codegen/orm/input-types-generator.d.ts +21 -0
- package/esm/cli/codegen/orm/input-types-generator.js +700 -0
- package/esm/cli/codegen/orm/input-types-generator.test.d.ts +1 -0
- package/esm/cli/codegen/orm/input-types-generator.test.js +73 -0
- package/esm/cli/codegen/orm/model-generator.d.ts +32 -0
- package/esm/cli/codegen/orm/model-generator.js +260 -0
- package/esm/cli/codegen/orm/query-builder.d.ts +161 -0
- package/esm/cli/codegen/orm/query-builder.js +353 -0
- package/esm/cli/codegen/orm/select-types.d.ts +169 -0
- package/esm/cli/codegen/orm/select-types.js +15 -0
- package/esm/cli/codegen/orm/select-types.test.d.ts +11 -0
- package/esm/cli/codegen/orm/select-types.test.js +21 -0
- package/esm/cli/codegen/queries.d.ts +25 -0
- package/esm/cli/codegen/queries.js +433 -0
- package/esm/cli/codegen/scalars.d.ts +12 -0
- package/esm/cli/codegen/scalars.js +66 -0
- package/esm/cli/codegen/schema-gql-ast.d.ts +51 -0
- package/esm/cli/codegen/schema-gql-ast.js +343 -0
- package/esm/cli/codegen/ts-ast.d.ts +122 -0
- package/esm/cli/codegen/ts-ast.js +260 -0
- package/esm/cli/codegen/type-resolver.d.ts +96 -0
- package/esm/cli/codegen/type-resolver.js +224 -0
- package/esm/cli/codegen/types.d.ts +12 -0
- package/esm/cli/codegen/types.js +65 -0
- package/esm/cli/codegen/utils.d.ts +163 -0
- package/esm/cli/codegen/utils.js +288 -0
- package/esm/cli/commands/generate-orm.d.ts +37 -0
- package/esm/cli/commands/generate-orm.js +192 -0
- package/esm/cli/commands/generate.d.ts +39 -0
- package/esm/cli/commands/generate.js +262 -0
- package/esm/cli/commands/index.d.ts +7 -0
- package/esm/cli/commands/index.js +5 -0
- package/esm/cli/commands/init.d.ts +35 -0
- package/esm/cli/commands/init.js +138 -0
- package/esm/cli/index.d.ts +4 -0
- package/esm/cli/index.js +256 -0
- package/esm/cli/introspect/fetch-meta.d.ts +31 -0
- package/esm/cli/introspect/fetch-meta.js +104 -0
- package/esm/cli/introspect/fetch-schema.d.ts +21 -0
- package/esm/cli/introspect/fetch-schema.js +83 -0
- package/esm/cli/introspect/index.d.ts +8 -0
- package/esm/cli/introspect/index.js +6 -0
- package/esm/cli/introspect/meta-query.d.ts +111 -0
- package/esm/cli/introspect/meta-query.js +188 -0
- package/esm/cli/introspect/schema-query.d.ts +20 -0
- package/esm/cli/introspect/schema-query.js +120 -0
- package/esm/cli/introspect/transform-schema.d.ts +74 -0
- package/esm/cli/introspect/transform-schema.js +259 -0
- package/esm/cli/introspect/transform-schema.test.d.ts +1 -0
- package/esm/cli/introspect/transform-schema.test.js +65 -0
- package/esm/cli/introspect/transform.d.ts +21 -0
- package/esm/cli/introspect/transform.js +210 -0
- package/esm/cli/watch/cache.d.ts +45 -0
- package/esm/cli/watch/cache.js +73 -0
- package/esm/cli/watch/debounce.d.ts +19 -0
- package/esm/cli/watch/debounce.js +85 -0
- package/esm/cli/watch/hash.d.ts +17 -0
- package/esm/cli/watch/hash.js +43 -0
- package/esm/cli/watch/index.d.ts +10 -0
- package/esm/cli/watch/index.js +8 -0
- package/esm/cli/watch/orchestrator.d.ts +63 -0
- package/esm/cli/watch/orchestrator.js +223 -0
- package/esm/cli/watch/poller.d.ts +65 -0
- package/esm/cli/watch/poller.js +198 -0
- package/esm/cli/watch/types.d.ts +67 -0
- package/esm/cli/watch/types.js +4 -0
- package/esm/client/error.d.ts +95 -0
- package/esm/client/error.js +249 -0
- package/esm/client/execute.d.ts +57 -0
- package/esm/client/execute.js +120 -0
- package/esm/client/index.d.ts +6 -0
- package/esm/client/index.js +6 -0
- package/esm/client/typed-document.d.ts +31 -0
- package/esm/client/typed-document.js +40 -0
- package/esm/core/ast.d.ts +10 -0
- package/esm/core/ast.js +549 -0
- package/esm/core/custom-ast.d.ts +35 -0
- package/esm/core/custom-ast.js +161 -0
- package/esm/core/index.d.ts +8 -0
- package/esm/core/index.js +12 -0
- package/esm/core/meta-object/convert.d.ts +65 -0
- package/esm/core/meta-object/convert.js +60 -0
- package/esm/core/meta-object/format.json +93 -0
- package/esm/core/meta-object/index.d.ts +2 -0
- package/esm/core/meta-object/index.js +2 -0
- package/esm/core/meta-object/validate.d.ts +9 -0
- package/esm/core/meta-object/validate.js +28 -0
- package/esm/core/query-builder.d.ts +46 -0
- package/esm/core/query-builder.js +375 -0
- package/esm/core/types.d.ts +139 -0
- package/esm/core/types.js +24 -0
- package/esm/generators/field-selector.d.ts +30 -0
- package/esm/generators/field-selector.js +355 -0
- package/esm/generators/index.d.ts +6 -0
- package/esm/generators/index.js +9 -0
- package/esm/generators/mutations.d.ts +31 -0
- package/esm/generators/mutations.js +197 -0
- package/esm/generators/select.d.ts +50 -0
- package/esm/generators/select.js +636 -0
- package/esm/index.d.ts +12 -0
- package/esm/index.js +17 -3
- package/esm/react/index.d.ts +5 -0
- package/esm/react/index.js +6 -0
- package/esm/types/config.d.ts +199 -0
- package/esm/types/config.js +106 -0
- package/esm/types/index.d.ts +9 -0
- package/esm/types/index.js +4 -0
- package/esm/types/introspection.d.ts +121 -0
- package/esm/types/introspection.js +54 -0
- package/esm/types/mutation.d.ts +45 -0
- package/esm/types/mutation.js +4 -0
- package/esm/types/query.d.ts +82 -0
- package/esm/types/query.js +4 -0
- package/esm/types/schema.d.ts +253 -0
- package/esm/types/schema.js +5 -0
- package/esm/types/selection.d.ts +43 -0
- package/esm/types/selection.js +4 -0
- package/esm/utils/index.d.ts +4 -0
- package/esm/utils/index.js +4 -0
- package/generators/field-selector.d.ts +30 -0
- package/generators/field-selector.js +361 -0
- package/generators/index.d.ts +6 -0
- package/generators/index.js +27 -0
- package/generators/mutations.d.ts +31 -0
- package/generators/mutations.js +235 -0
- package/generators/select.d.ts +50 -0
- package/generators/select.js +679 -0
- package/index.d.ts +12 -3
- package/index.js +19 -3
- package/package.json +59 -38
- package/react/index.d.ts +5 -0
- package/react/index.js +9 -0
- package/types/config.d.ts +199 -0
- package/types/config.js +111 -0
- package/types/index.d.ts +9 -0
- package/types/index.js +10 -0
- package/types/introspection.d.ts +121 -0
- package/types/introspection.js +62 -0
- package/types/mutation.d.ts +45 -0
- package/types/mutation.js +5 -0
- package/types/query.d.ts +82 -0
- package/types/query.js +5 -0
- package/types/schema.d.ts +253 -0
- package/types/schema.js +6 -0
- package/types/selection.d.ts +43 -0
- package/types/selection.js +5 -0
- package/utils/index.d.ts +4 -0
- package/utils/index.js +7 -0
- package/codegen.d.ts +0 -13
- package/codegen.js +0 -293
- package/esm/codegen.js +0 -253
- package/esm/gql.js +0 -939
- package/esm/options.js +0 -27
- package/gql.d.ts +0 -188
- package/gql.js +0 -992
- package/options.d.ts +0 -45
- package/options.js +0 -31
package/index.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @constructive-io/graphql-codegen
|
|
4
|
+
*
|
|
5
|
+
* CLI-based GraphQL SDK generator for PostGraphile endpoints.
|
|
6
|
+
* Introspects via _meta query and generates typed queries, mutations,
|
|
7
|
+
* and React Query v5 hooks.
|
|
8
|
+
*/
|
|
2
9
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
10
|
if (k2 === undefined) k2 = k;
|
|
4
11
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -14,6 +21,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
21
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
22
|
};
|
|
16
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
__exportStar(require("./
|
|
24
|
+
exports.defineConfig = void 0;
|
|
25
|
+
// Core types
|
|
26
|
+
__exportStar(require("./types"), exports);
|
|
27
|
+
// Core query building
|
|
28
|
+
__exportStar(require("./core"), exports);
|
|
29
|
+
// Generators
|
|
30
|
+
__exportStar(require("./generators"), exports);
|
|
31
|
+
// Client utilities
|
|
32
|
+
__exportStar(require("./client"), exports);
|
|
33
|
+
// Config definition helper
|
|
34
|
+
var config_1 = require("./types/config");
|
|
35
|
+
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.20.0",
|
|
4
|
+
"description": "CLI-based GraphQL SDK generator for PostGraphile endpoints with React Query hooks",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"graphql",
|
|
7
|
+
"postgraphile",
|
|
8
|
+
"codegen",
|
|
9
|
+
"react-query",
|
|
10
|
+
"tanstack-query",
|
|
11
|
+
"typescript",
|
|
12
|
+
"graphile",
|
|
13
|
+
"constructive"
|
|
14
|
+
],
|
|
5
15
|
"author": "Constructive <developers@constructive.io>",
|
|
6
|
-
"main": "index.js",
|
|
7
|
-
"module": "esm/index.js",
|
|
8
|
-
"types": "index.d.ts",
|
|
9
|
-
"homepage": "https://github.com/constructive-io/constructive",
|
|
10
16
|
"license": "MIT",
|
|
11
|
-
"
|
|
12
|
-
"access": "public",
|
|
13
|
-
"directory": "dist"
|
|
14
|
-
},
|
|
17
|
+
"homepage": "https://github.com/constructive-io/constructive",
|
|
15
18
|
"repository": {
|
|
16
19
|
"type": "git",
|
|
17
20
|
"url": "https://github.com/constructive-io/constructive"
|
|
@@ -19,43 +22,61 @@
|
|
|
19
22
|
"bugs": {
|
|
20
23
|
"url": "https://github.com/constructive-io/constructive/issues"
|
|
21
24
|
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public",
|
|
27
|
+
"directory": "dist"
|
|
28
|
+
},
|
|
29
|
+
"main": "index.js",
|
|
30
|
+
"module": "index.mjs",
|
|
31
|
+
"types": "index.d.ts",
|
|
32
|
+
"bin": {
|
|
33
|
+
"graphql-codegen": "index.js"
|
|
34
|
+
},
|
|
22
35
|
"scripts": {
|
|
23
36
|
"clean": "makage clean",
|
|
24
37
|
"prepack": "npm run build",
|
|
25
38
|
"build": "makage build",
|
|
26
39
|
"build:dev": "makage build --dev",
|
|
40
|
+
"dev": "ts-node ./src/index.ts",
|
|
27
41
|
"lint": "eslint . --fix",
|
|
28
42
|
"test": "jest --passWithNoTests",
|
|
29
|
-
"test:watch": "jest --watch"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
"@types/babel__generator": "^7.27.0",
|
|
34
|
-
"@types/inflection": "^2.0.0",
|
|
35
|
-
"makage": "^0.1.10"
|
|
43
|
+
"test:watch": "jest --watch",
|
|
44
|
+
"example:orm": "tsx examples/test-orm.ts",
|
|
45
|
+
"example:rq": "tsx examples/test-rq.ts",
|
|
46
|
+
"example:schema": "tsx examples/download-schema.ts"
|
|
36
47
|
},
|
|
37
48
|
"dependencies": {
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"@babel/types": "^7.26.3",
|
|
41
|
-
"@graphql-codegen/core": "5.0.0",
|
|
42
|
-
"@graphql-codegen/typescript": "5.0.5",
|
|
43
|
-
"@graphql-codegen/typescript-graphql-request": "6.0.1",
|
|
44
|
-
"@graphql-codegen/typescript-operations": "5.0.5",
|
|
45
|
-
"@graphql-codegen/typescript-react-query": "6.1.1",
|
|
49
|
+
"ajv": "^8.17.1",
|
|
50
|
+
"commander": "^12.1.0",
|
|
46
51
|
"gql-ast": "^2.4.6",
|
|
47
|
-
"graphql": "15.
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
+
"graphql": "15.8.0",
|
|
53
|
+
"inflection": "^3.0.2",
|
|
54
|
+
"jiti": "^2.6.1",
|
|
55
|
+
"prettier": "^3.7.4",
|
|
56
|
+
"ts-morph": "^27.0.2"
|
|
52
57
|
},
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@tanstack/react-query": "^5.0.0",
|
|
60
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@tanstack/react-query": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"react": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@tanstack/react-query": "^5.90.16",
|
|
72
|
+
"@types/inflection": "^1.13.2",
|
|
73
|
+
"@types/jest": "^29.5.14",
|
|
74
|
+
"@types/node": "^20.19.27",
|
|
75
|
+
"@types/react": "^19.2.7",
|
|
76
|
+
"jest": "^29.7.0",
|
|
77
|
+
"react": "^19.2.3",
|
|
78
|
+
"ts-jest": "^29.2.5",
|
|
79
|
+
"typescript": "^5.9.3"
|
|
80
|
+
},
|
|
81
|
+
"gitHead": "baa2f7598cde3baf3f05f161a11bafa12c66f6aa"
|
|
61
82
|
}
|
package/react/index.d.ts
ADDED
package/react/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* React integration exports
|
|
4
|
+
* Will be populated in Phase 8
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.REACT_VERSION = void 0;
|
|
8
|
+
// Placeholder exports - will be implemented
|
|
9
|
+
exports.REACT_VERSION = '0.1.0';
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SDK Configuration types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Main configuration for graphql-codegen
|
|
6
|
+
*/
|
|
7
|
+
export interface GraphQLSDKConfig {
|
|
8
|
+
/**
|
|
9
|
+
* GraphQL endpoint URL (must expose _meta query)
|
|
10
|
+
*/
|
|
11
|
+
endpoint: string;
|
|
12
|
+
/**
|
|
13
|
+
* Headers to include in introspection requests
|
|
14
|
+
*/
|
|
15
|
+
headers?: Record<string, string>;
|
|
16
|
+
/**
|
|
17
|
+
* Output directory for generated code
|
|
18
|
+
* @default './generated/graphql'
|
|
19
|
+
*/
|
|
20
|
+
output?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Table filtering options (for table-based CRUD operations from _meta)
|
|
23
|
+
*/
|
|
24
|
+
tables?: {
|
|
25
|
+
/** Tables to include (glob patterns supported) */
|
|
26
|
+
include?: string[];
|
|
27
|
+
/** Tables to exclude (glob patterns supported) */
|
|
28
|
+
exclude?: string[];
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Query operation filtering (for ALL queries from __schema introspection)
|
|
32
|
+
* Glob patterns supported (e.g., 'current*', '*ByUsername')
|
|
33
|
+
*/
|
|
34
|
+
queries?: {
|
|
35
|
+
/** Query names to include - defaults to ['*'] */
|
|
36
|
+
include?: string[];
|
|
37
|
+
/** Query names to exclude - defaults to ['_meta', 'query'] */
|
|
38
|
+
exclude?: string[];
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Mutation operation filtering (for ALL mutations from __schema introspection)
|
|
42
|
+
* Glob patterns supported (e.g., 'create*', 'login', 'register')
|
|
43
|
+
*/
|
|
44
|
+
mutations?: {
|
|
45
|
+
/** Mutation names to include - defaults to ['*'] */
|
|
46
|
+
include?: string[];
|
|
47
|
+
/** Mutation names to exclude */
|
|
48
|
+
exclude?: string[];
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Fields to exclude globally from all tables
|
|
52
|
+
*/
|
|
53
|
+
excludeFields?: string[];
|
|
54
|
+
/**
|
|
55
|
+
* Hook generation options
|
|
56
|
+
*/
|
|
57
|
+
hooks?: {
|
|
58
|
+
/** Generate query hooks */
|
|
59
|
+
queries?: boolean;
|
|
60
|
+
/** Generate mutation hooks */
|
|
61
|
+
mutations?: boolean;
|
|
62
|
+
/** Prefix for query keys */
|
|
63
|
+
queryKeyPrefix?: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* PostGraphile-specific options
|
|
67
|
+
*/
|
|
68
|
+
postgraphile?: {
|
|
69
|
+
/** PostgreSQL schema to introspect */
|
|
70
|
+
schema?: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Code generation options
|
|
74
|
+
*/
|
|
75
|
+
codegen?: {
|
|
76
|
+
/** Max depth for nested object field selection (default: 2) */
|
|
77
|
+
maxFieldDepth?: number;
|
|
78
|
+
/** Skip 'query' field on mutation payloads (default: true) */
|
|
79
|
+
skipQueryField?: boolean;
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* ORM client generation options
|
|
83
|
+
* When set, generates a Prisma-like ORM client in addition to or instead of React Query hooks
|
|
84
|
+
*/
|
|
85
|
+
orm?: {
|
|
86
|
+
/**
|
|
87
|
+
* Output directory for generated ORM client
|
|
88
|
+
* @default './generated/orm'
|
|
89
|
+
*/
|
|
90
|
+
output?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Whether to import shared types from hooks output or generate standalone
|
|
93
|
+
* When true, ORM types.ts will re-export from ../graphql/types
|
|
94
|
+
* @default true
|
|
95
|
+
*/
|
|
96
|
+
useSharedTypes?: boolean;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Watch mode configuration (dev-only feature)
|
|
100
|
+
* When enabled via CLI --watch flag, the CLI will poll the endpoint for schema changes
|
|
101
|
+
*/
|
|
102
|
+
watch?: WatchConfig;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Watch mode configuration options
|
|
106
|
+
*
|
|
107
|
+
* Watch mode uses in-memory caching for efficiency - no file I/O during polling.
|
|
108
|
+
*/
|
|
109
|
+
export interface WatchConfig {
|
|
110
|
+
/**
|
|
111
|
+
* Polling interval in milliseconds
|
|
112
|
+
* @default 3000
|
|
113
|
+
*/
|
|
114
|
+
pollInterval?: number;
|
|
115
|
+
/**
|
|
116
|
+
* Debounce delay in milliseconds before regenerating
|
|
117
|
+
* Prevents rapid regeneration during schema migrations
|
|
118
|
+
* @default 800
|
|
119
|
+
*/
|
|
120
|
+
debounce?: number;
|
|
121
|
+
/**
|
|
122
|
+
* File to touch on schema change (useful for triggering external tools like tsc/webpack)
|
|
123
|
+
* This is the only file I/O in watch mode.
|
|
124
|
+
* @example '.trigger'
|
|
125
|
+
*/
|
|
126
|
+
touchFile?: string;
|
|
127
|
+
/**
|
|
128
|
+
* Clear terminal on regeneration
|
|
129
|
+
* @default true
|
|
130
|
+
*/
|
|
131
|
+
clearScreen?: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Resolved watch configuration with defaults applied
|
|
135
|
+
*/
|
|
136
|
+
export interface ResolvedWatchConfig {
|
|
137
|
+
pollInterval: number;
|
|
138
|
+
debounce: number;
|
|
139
|
+
touchFile: string | null;
|
|
140
|
+
clearScreen: boolean;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Resolved configuration with defaults applied
|
|
144
|
+
*/
|
|
145
|
+
export interface ResolvedConfig extends Required<Omit<GraphQLSDKConfig, 'headers' | 'tables' | 'queries' | 'mutations' | 'hooks' | 'postgraphile' | 'codegen' | 'orm' | 'watch'>> {
|
|
146
|
+
headers: Record<string, string>;
|
|
147
|
+
tables: {
|
|
148
|
+
include: string[];
|
|
149
|
+
exclude: string[];
|
|
150
|
+
};
|
|
151
|
+
queries: {
|
|
152
|
+
include: string[];
|
|
153
|
+
exclude: string[];
|
|
154
|
+
};
|
|
155
|
+
mutations: {
|
|
156
|
+
include: string[];
|
|
157
|
+
exclude: string[];
|
|
158
|
+
};
|
|
159
|
+
hooks: {
|
|
160
|
+
queries: boolean;
|
|
161
|
+
mutations: boolean;
|
|
162
|
+
queryKeyPrefix: string;
|
|
163
|
+
};
|
|
164
|
+
postgraphile: {
|
|
165
|
+
schema: string;
|
|
166
|
+
};
|
|
167
|
+
codegen: {
|
|
168
|
+
maxFieldDepth: number;
|
|
169
|
+
skipQueryField: boolean;
|
|
170
|
+
};
|
|
171
|
+
orm: {
|
|
172
|
+
output: string;
|
|
173
|
+
useSharedTypes: boolean;
|
|
174
|
+
} | null;
|
|
175
|
+
watch: ResolvedWatchConfig;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Default watch configuration values
|
|
179
|
+
*/
|
|
180
|
+
export declare const DEFAULT_WATCH_CONFIG: ResolvedWatchConfig;
|
|
181
|
+
/**
|
|
182
|
+
* Default configuration values
|
|
183
|
+
*/
|
|
184
|
+
export declare const DEFAULT_CONFIG: Omit<ResolvedConfig, 'endpoint'>;
|
|
185
|
+
/**
|
|
186
|
+
* Default ORM configuration values
|
|
187
|
+
*/
|
|
188
|
+
export declare const DEFAULT_ORM_CONFIG: {
|
|
189
|
+
output: string;
|
|
190
|
+
useSharedTypes: boolean;
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* Helper function to define configuration with type checking
|
|
194
|
+
*/
|
|
195
|
+
export declare function defineConfig(config: GraphQLSDKConfig): GraphQLSDKConfig;
|
|
196
|
+
/**
|
|
197
|
+
* Resolve configuration by applying defaults
|
|
198
|
+
*/
|
|
199
|
+
export declare function resolveConfig(config: GraphQLSDKConfig): ResolvedConfig;
|
package/types/config.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* SDK Configuration types
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_ORM_CONFIG = exports.DEFAULT_CONFIG = exports.DEFAULT_WATCH_CONFIG = void 0;
|
|
7
|
+
exports.defineConfig = defineConfig;
|
|
8
|
+
exports.resolveConfig = resolveConfig;
|
|
9
|
+
/**
|
|
10
|
+
* Default watch configuration values
|
|
11
|
+
*/
|
|
12
|
+
exports.DEFAULT_WATCH_CONFIG = {
|
|
13
|
+
pollInterval: 3000,
|
|
14
|
+
debounce: 800,
|
|
15
|
+
touchFile: null,
|
|
16
|
+
clearScreen: true,
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Default configuration values
|
|
20
|
+
*/
|
|
21
|
+
exports.DEFAULT_CONFIG = {
|
|
22
|
+
headers: {},
|
|
23
|
+
output: './generated/graphql',
|
|
24
|
+
tables: {
|
|
25
|
+
include: ['*'],
|
|
26
|
+
exclude: [],
|
|
27
|
+
},
|
|
28
|
+
queries: {
|
|
29
|
+
include: ['*'],
|
|
30
|
+
exclude: ['_meta', 'query'], // Internal PostGraphile queries
|
|
31
|
+
},
|
|
32
|
+
mutations: {
|
|
33
|
+
include: ['*'],
|
|
34
|
+
exclude: [],
|
|
35
|
+
},
|
|
36
|
+
excludeFields: [],
|
|
37
|
+
hooks: {
|
|
38
|
+
queries: true,
|
|
39
|
+
mutations: true,
|
|
40
|
+
queryKeyPrefix: 'graphql',
|
|
41
|
+
},
|
|
42
|
+
postgraphile: {
|
|
43
|
+
schema: 'public',
|
|
44
|
+
},
|
|
45
|
+
codegen: {
|
|
46
|
+
maxFieldDepth: 2,
|
|
47
|
+
skipQueryField: true,
|
|
48
|
+
},
|
|
49
|
+
orm: null, // ORM generation disabled by default
|
|
50
|
+
watch: exports.DEFAULT_WATCH_CONFIG,
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Default ORM configuration values
|
|
54
|
+
*/
|
|
55
|
+
exports.DEFAULT_ORM_CONFIG = {
|
|
56
|
+
output: './generated/orm',
|
|
57
|
+
useSharedTypes: true,
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Helper function to define configuration with type checking
|
|
61
|
+
*/
|
|
62
|
+
function defineConfig(config) {
|
|
63
|
+
return config;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Resolve configuration by applying defaults
|
|
67
|
+
*/
|
|
68
|
+
function resolveConfig(config) {
|
|
69
|
+
return {
|
|
70
|
+
endpoint: config.endpoint,
|
|
71
|
+
headers: config.headers ?? exports.DEFAULT_CONFIG.headers,
|
|
72
|
+
output: config.output ?? exports.DEFAULT_CONFIG.output,
|
|
73
|
+
tables: {
|
|
74
|
+
include: config.tables?.include ?? exports.DEFAULT_CONFIG.tables.include,
|
|
75
|
+
exclude: config.tables?.exclude ?? exports.DEFAULT_CONFIG.tables.exclude,
|
|
76
|
+
},
|
|
77
|
+
queries: {
|
|
78
|
+
include: config.queries?.include ?? exports.DEFAULT_CONFIG.queries.include,
|
|
79
|
+
exclude: config.queries?.exclude ?? exports.DEFAULT_CONFIG.queries.exclude,
|
|
80
|
+
},
|
|
81
|
+
mutations: {
|
|
82
|
+
include: config.mutations?.include ?? exports.DEFAULT_CONFIG.mutations.include,
|
|
83
|
+
exclude: config.mutations?.exclude ?? exports.DEFAULT_CONFIG.mutations.exclude,
|
|
84
|
+
},
|
|
85
|
+
excludeFields: config.excludeFields ?? exports.DEFAULT_CONFIG.excludeFields,
|
|
86
|
+
hooks: {
|
|
87
|
+
queries: config.hooks?.queries ?? exports.DEFAULT_CONFIG.hooks.queries,
|
|
88
|
+
mutations: config.hooks?.mutations ?? exports.DEFAULT_CONFIG.hooks.mutations,
|
|
89
|
+
queryKeyPrefix: config.hooks?.queryKeyPrefix ?? exports.DEFAULT_CONFIG.hooks.queryKeyPrefix,
|
|
90
|
+
},
|
|
91
|
+
postgraphile: {
|
|
92
|
+
schema: config.postgraphile?.schema ?? exports.DEFAULT_CONFIG.postgraphile.schema,
|
|
93
|
+
},
|
|
94
|
+
codegen: {
|
|
95
|
+
maxFieldDepth: config.codegen?.maxFieldDepth ?? exports.DEFAULT_CONFIG.codegen.maxFieldDepth,
|
|
96
|
+
skipQueryField: config.codegen?.skipQueryField ?? exports.DEFAULT_CONFIG.codegen.skipQueryField,
|
|
97
|
+
},
|
|
98
|
+
orm: config.orm
|
|
99
|
+
? {
|
|
100
|
+
output: config.orm.output ?? exports.DEFAULT_ORM_CONFIG.output,
|
|
101
|
+
useSharedTypes: config.orm.useSharedTypes ?? exports.DEFAULT_ORM_CONFIG.useSharedTypes,
|
|
102
|
+
}
|
|
103
|
+
: null,
|
|
104
|
+
watch: {
|
|
105
|
+
pollInterval: config.watch?.pollInterval ?? exports.DEFAULT_WATCH_CONFIG.pollInterval,
|
|
106
|
+
debounce: config.watch?.debounce ?? exports.DEFAULT_WATCH_CONFIG.debounce,
|
|
107
|
+
touchFile: config.watch?.touchFile ?? exports.DEFAULT_WATCH_CONFIG.touchFile,
|
|
108
|
+
clearScreen: config.watch?.clearScreen ?? exports.DEFAULT_WATCH_CONFIG.clearScreen,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type exports for @constructive-io/graphql-codegen
|
|
3
|
+
*/
|
|
4
|
+
export type { CleanTable, CleanField, CleanFieldType, CleanRelations, CleanBelongsToRelation, CleanHasOneRelation, CleanHasManyRelation, CleanManyToManyRelation, TableInflection, TableQueryNames, TableConstraints, ConstraintInfo, ForeignKeyConstraint, } from './schema';
|
|
5
|
+
export type { PageInfo, ConnectionResult, QueryOptions, OrderByItem, FilterOperator, FieldFilter, RelationalFilter, Filter, } from './query';
|
|
6
|
+
export type { MutationOptions, CreateInput, UpdateInput, DeleteInput, MutationResult, } from './mutation';
|
|
7
|
+
export type { SimpleFieldSelection, FieldSelectionPreset, FieldSelection, SelectionOptions, } from './selection';
|
|
8
|
+
export type { GraphQLSDKConfig, ResolvedConfig, } from './config';
|
|
9
|
+
export { defineConfig, resolveConfig, DEFAULT_CONFIG } from './config';
|
package/types/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type exports for @constructive-io/graphql-codegen
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DEFAULT_CONFIG = exports.resolveConfig = exports.defineConfig = void 0;
|
|
7
|
+
var config_1 = require("./config");
|
|
8
|
+
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
|
|
9
|
+
Object.defineProperty(exports, "resolveConfig", { enumerable: true, get: function () { return config_1.resolveConfig; } });
|
|
10
|
+
Object.defineProperty(exports, "DEFAULT_CONFIG", { enumerable: true, get: function () { return config_1.DEFAULT_CONFIG; } });
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GraphQL Introspection Types
|
|
3
|
+
*
|
|
4
|
+
* Standard types for GraphQL schema introspection via __schema query.
|
|
5
|
+
* These mirror the GraphQL introspection spec.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Reference to a GraphQL type - can be nested for wrappers like NON_NULL and LIST
|
|
9
|
+
*/
|
|
10
|
+
export interface IntrospectionTypeRef {
|
|
11
|
+
kind: IntrospectionTypeKind;
|
|
12
|
+
name: string | null;
|
|
13
|
+
ofType: IntrospectionTypeRef | null;
|
|
14
|
+
}
|
|
15
|
+
export type IntrospectionTypeKind = 'SCALAR' | 'OBJECT' | 'INPUT_OBJECT' | 'ENUM' | 'LIST' | 'NON_NULL' | 'INTERFACE' | 'UNION';
|
|
16
|
+
/**
|
|
17
|
+
* Input value - used for both field arguments and INPUT_OBJECT fields
|
|
18
|
+
*/
|
|
19
|
+
export interface IntrospectionInputValue {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string | null;
|
|
22
|
+
type: IntrospectionTypeRef;
|
|
23
|
+
defaultValue: string | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Field on an OBJECT or INTERFACE type
|
|
27
|
+
*/
|
|
28
|
+
export interface IntrospectionField {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string | null;
|
|
31
|
+
args: IntrospectionInputValue[];
|
|
32
|
+
type: IntrospectionTypeRef;
|
|
33
|
+
isDeprecated: boolean;
|
|
34
|
+
deprecationReason: string | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Enum value definition
|
|
38
|
+
*/
|
|
39
|
+
export interface IntrospectionEnumValue {
|
|
40
|
+
name: string;
|
|
41
|
+
description: string | null;
|
|
42
|
+
isDeprecated: boolean;
|
|
43
|
+
deprecationReason: string | null;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Complete type definition from introspection
|
|
47
|
+
*/
|
|
48
|
+
export interface IntrospectionType {
|
|
49
|
+
kind: IntrospectionTypeKind;
|
|
50
|
+
name: string;
|
|
51
|
+
description: string | null;
|
|
52
|
+
/** Fields for OBJECT and INTERFACE types */
|
|
53
|
+
fields: IntrospectionField[] | null;
|
|
54
|
+
/** Input fields for INPUT_OBJECT types */
|
|
55
|
+
inputFields: IntrospectionInputValue[] | null;
|
|
56
|
+
/** Possible types for INTERFACE and UNION types */
|
|
57
|
+
possibleTypes: Array<{
|
|
58
|
+
name: string;
|
|
59
|
+
}> | null;
|
|
60
|
+
/** Enum values for ENUM types */
|
|
61
|
+
enumValues: IntrospectionEnumValue[] | null;
|
|
62
|
+
/** Interfaces implemented by OBJECT types */
|
|
63
|
+
interfaces: Array<{
|
|
64
|
+
name: string;
|
|
65
|
+
}> | null;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Root type references in schema
|
|
69
|
+
*/
|
|
70
|
+
export interface IntrospectionRootType {
|
|
71
|
+
name: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Full schema introspection result
|
|
75
|
+
*/
|
|
76
|
+
export interface IntrospectionSchema {
|
|
77
|
+
queryType: IntrospectionRootType;
|
|
78
|
+
mutationType: IntrospectionRootType | null;
|
|
79
|
+
subscriptionType: IntrospectionRootType | null;
|
|
80
|
+
types: IntrospectionType[];
|
|
81
|
+
directives: IntrospectionDirective[];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Directive definition
|
|
85
|
+
*/
|
|
86
|
+
export interface IntrospectionDirective {
|
|
87
|
+
name: string;
|
|
88
|
+
description: string | null;
|
|
89
|
+
locations: string[];
|
|
90
|
+
args: IntrospectionInputValue[];
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Response from introspection query
|
|
94
|
+
*/
|
|
95
|
+
export interface IntrospectionQueryResponse {
|
|
96
|
+
__schema: IntrospectionSchema;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if type kind is a wrapper (LIST or NON_NULL)
|
|
100
|
+
*/
|
|
101
|
+
export declare function isWrapperType(kind: IntrospectionTypeKind): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Check if type kind is a named type (has a name)
|
|
104
|
+
*/
|
|
105
|
+
export declare function isNamedType(kind: IntrospectionTypeKind): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Unwrap a type reference to get the base named type
|
|
108
|
+
*/
|
|
109
|
+
export declare function unwrapType(typeRef: IntrospectionTypeRef): IntrospectionTypeRef;
|
|
110
|
+
/**
|
|
111
|
+
* Get the base type name from a possibly wrapped type
|
|
112
|
+
*/
|
|
113
|
+
export declare function getBaseTypeName(typeRef: IntrospectionTypeRef): string | null;
|
|
114
|
+
/**
|
|
115
|
+
* Check if a type reference is non-null (required)
|
|
116
|
+
*/
|
|
117
|
+
export declare function isNonNull(typeRef: IntrospectionTypeRef): boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Check if a type reference is a list
|
|
120
|
+
*/
|
|
121
|
+
export declare function isList(typeRef: IntrospectionTypeRef): boolean;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GraphQL Introspection Types
|
|
4
|
+
*
|
|
5
|
+
* Standard types for GraphQL schema introspection via __schema query.
|
|
6
|
+
* These mirror the GraphQL introspection spec.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.isWrapperType = isWrapperType;
|
|
10
|
+
exports.isNamedType = isNamedType;
|
|
11
|
+
exports.unwrapType = unwrapType;
|
|
12
|
+
exports.getBaseTypeName = getBaseTypeName;
|
|
13
|
+
exports.isNonNull = isNonNull;
|
|
14
|
+
exports.isList = isList;
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Type Guards
|
|
17
|
+
// ============================================================================
|
|
18
|
+
/**
|
|
19
|
+
* Check if type kind is a wrapper (LIST or NON_NULL)
|
|
20
|
+
*/
|
|
21
|
+
function isWrapperType(kind) {
|
|
22
|
+
return kind === 'LIST' || kind === 'NON_NULL';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if type kind is a named type (has a name)
|
|
26
|
+
*/
|
|
27
|
+
function isNamedType(kind) {
|
|
28
|
+
return !isWrapperType(kind);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Unwrap a type reference to get the base named type
|
|
32
|
+
*/
|
|
33
|
+
function unwrapType(typeRef) {
|
|
34
|
+
let current = typeRef;
|
|
35
|
+
while (current.ofType) {
|
|
36
|
+
current = current.ofType;
|
|
37
|
+
}
|
|
38
|
+
return current;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the base type name from a possibly wrapped type
|
|
42
|
+
*/
|
|
43
|
+
function getBaseTypeName(typeRef) {
|
|
44
|
+
return unwrapType(typeRef).name;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Check if a type reference is non-null (required)
|
|
48
|
+
*/
|
|
49
|
+
function isNonNull(typeRef) {
|
|
50
|
+
return typeRef.kind === 'NON_NULL';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Check if a type reference is a list
|
|
54
|
+
*/
|
|
55
|
+
function isList(typeRef) {
|
|
56
|
+
if (typeRef.kind === 'LIST')
|
|
57
|
+
return true;
|
|
58
|
+
if (typeRef.kind === 'NON_NULL' && typeRef.ofType) {
|
|
59
|
+
return typeRef.ofType.kind === 'LIST';
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|