@constructive-io/graphql-codegen 5.13.3 → 5.13.5
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/core/introspect/enrich-relations.d.ts +1 -1
- package/core/introspect/source/database.d.ts +5 -0
- package/core/introspect/source/database.js +9 -5
- package/esm/core/introspect/enrich-relations.d.ts +1 -1
- package/esm/core/introspect/source/database.d.ts +5 -0
- package/esm/core/introspect/source/database.js +10 -6
- package/package.json +12 -12
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* M:N Relation Enrichment
|
|
3
3
|
*
|
|
4
4
|
* After table inference from introspection, enriches ManyToManyRelation objects
|
|
5
|
-
* with junction key field metadata from
|
|
5
|
+
* with junction key field metadata from the schema-correlated tablesMeta (MetaSchemaPlugin).
|
|
6
6
|
*/
|
|
7
7
|
import type { Table } from '../../types/schema';
|
|
8
8
|
import type { MetaTableInfo } from './source/types';
|
|
@@ -17,6 +17,11 @@ export interface DatabaseSchemaSourceOptions {
|
|
|
17
17
|
* Mutually exclusive with schemas
|
|
18
18
|
*/
|
|
19
19
|
apiNames?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* @internal Test-only. Forwarded to `buildSchemaArtifacts` so regression
|
|
22
|
+
* tests can deterministically interleave concurrent builds.
|
|
23
|
+
*/
|
|
24
|
+
_onMetaCollected?: () => Promise<void>;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* Schema source that loads from a PostgreSQL database
|
|
@@ -6,7 +6,8 @@ exports.DatabaseSchemaSource = void 0;
|
|
|
6
6
|
*
|
|
7
7
|
* Loads GraphQL schema directly from a PostgreSQL database using PostGraphile
|
|
8
8
|
* introspection and converts it to introspection format.
|
|
9
|
-
* Also returns _meta table metadata
|
|
9
|
+
* Also returns _meta table metadata correlated to the same schema build
|
|
10
|
+
* (via buildSchemaArtifacts).
|
|
10
11
|
*/
|
|
11
12
|
const graphql_1 = require("graphql");
|
|
12
13
|
const graphile_schema_1 = require("graphile-schema");
|
|
@@ -46,13 +47,16 @@ class DatabaseSchemaSource {
|
|
|
46
47
|
else {
|
|
47
48
|
schemas = this.options.schemas ?? ['public'];
|
|
48
49
|
}
|
|
49
|
-
// Build SDL from
|
|
50
|
+
// Build SDL and _meta metadata from one correlated build boundary so the
|
|
51
|
+
// returned pair always describes the same GraphQLSchema.
|
|
50
52
|
let sdl;
|
|
53
|
+
let tablesMeta;
|
|
51
54
|
try {
|
|
52
|
-
sdl = await (0, graphile_schema_1.
|
|
55
|
+
({ sdl, tablesMeta } = await (0, graphile_schema_1.buildSchemaArtifacts)({
|
|
53
56
|
database,
|
|
54
57
|
schemas,
|
|
55
|
-
|
|
58
|
+
_onMetaCollected: this.options._onMetaCollected,
|
|
59
|
+
}));
|
|
56
60
|
}
|
|
57
61
|
catch (err) {
|
|
58
62
|
throw new types_1.SchemaSourceError(`Failed to introspect database: ${err instanceof Error ? err.message : 'Unknown error'}`, this.describe(), err instanceof Error ? err : undefined);
|
|
@@ -81,7 +85,7 @@ class DatabaseSchemaSource {
|
|
|
81
85
|
const introspection = JSON.parse(JSON.stringify(introspectionResult));
|
|
82
86
|
return {
|
|
83
87
|
introspection,
|
|
84
|
-
tablesMeta:
|
|
88
|
+
tablesMeta: tablesMeta,
|
|
85
89
|
};
|
|
86
90
|
}
|
|
87
91
|
describe() {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* M:N Relation Enrichment
|
|
3
3
|
*
|
|
4
4
|
* After table inference from introspection, enriches ManyToManyRelation objects
|
|
5
|
-
* with junction key field metadata from
|
|
5
|
+
* with junction key field metadata from the schema-correlated tablesMeta (MetaSchemaPlugin).
|
|
6
6
|
*/
|
|
7
7
|
import type { Table } from '../../types/schema';
|
|
8
8
|
import type { MetaTableInfo } from './source/types';
|
|
@@ -17,6 +17,11 @@ export interface DatabaseSchemaSourceOptions {
|
|
|
17
17
|
* Mutually exclusive with schemas
|
|
18
18
|
*/
|
|
19
19
|
apiNames?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* @internal Test-only. Forwarded to `buildSchemaArtifacts` so regression
|
|
22
|
+
* tests can deterministically interleave concurrent builds.
|
|
23
|
+
*/
|
|
24
|
+
_onMetaCollected?: () => Promise<void>;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* Schema source that loads from a PostgreSQL database
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Loads GraphQL schema directly from a PostgreSQL database using PostGraphile
|
|
5
5
|
* introspection and converts it to introspection format.
|
|
6
|
-
* Also returns _meta table metadata
|
|
6
|
+
* Also returns _meta table metadata correlated to the same schema build
|
|
7
|
+
* (via buildSchemaArtifacts).
|
|
7
8
|
*/
|
|
8
9
|
import { buildSchema, introspectionFromSchema } from 'graphql';
|
|
9
|
-
import {
|
|
10
|
+
import { buildSchemaArtifacts } from 'graphile-schema';
|
|
10
11
|
import { createDatabasePool, resolveApiSchemas, validateRoutingSchemas, } from './api-schemas';
|
|
11
12
|
import { SchemaSourceError } from './types';
|
|
12
13
|
/**
|
|
@@ -43,13 +44,16 @@ export class DatabaseSchemaSource {
|
|
|
43
44
|
else {
|
|
44
45
|
schemas = this.options.schemas ?? ['public'];
|
|
45
46
|
}
|
|
46
|
-
// Build SDL from
|
|
47
|
+
// Build SDL and _meta metadata from one correlated build boundary so the
|
|
48
|
+
// returned pair always describes the same GraphQLSchema.
|
|
47
49
|
let sdl;
|
|
50
|
+
let tablesMeta;
|
|
48
51
|
try {
|
|
49
|
-
sdl = await
|
|
52
|
+
({ sdl, tablesMeta } = await buildSchemaArtifacts({
|
|
50
53
|
database,
|
|
51
54
|
schemas,
|
|
52
|
-
|
|
55
|
+
_onMetaCollected: this.options._onMetaCollected,
|
|
56
|
+
}));
|
|
53
57
|
}
|
|
54
58
|
catch (err) {
|
|
55
59
|
throw new SchemaSourceError(`Failed to introspect database: ${err instanceof Error ? err.message : 'Unknown error'}`, this.describe(), err instanceof Error ? err : undefined);
|
|
@@ -78,7 +82,7 @@ export class DatabaseSchemaSource {
|
|
|
78
82
|
const introspection = JSON.parse(JSON.stringify(introspectionResult));
|
|
79
83
|
return {
|
|
80
84
|
introspection,
|
|
81
|
-
tablesMeta:
|
|
85
|
+
tablesMeta: tablesMeta,
|
|
82
86
|
};
|
|
83
87
|
}
|
|
84
88
|
describe() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-codegen",
|
|
3
|
-
"version": "5.13.
|
|
3
|
+
"version": "5.13.5",
|
|
4
4
|
"description": "GraphQL SDK generator for Constructive databases with React Query hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"graphql",
|
|
@@ -56,25 +56,25 @@
|
|
|
56
56
|
"@0no-co/graphql.web": "^1.1.2",
|
|
57
57
|
"@babel/generator": "^7.29.1",
|
|
58
58
|
"@babel/types": "^7.29.0",
|
|
59
|
-
"@constructive-io/graphql-query": "^4.11.
|
|
60
|
-
"@constructive-io/graphql-types": "^3.27.
|
|
59
|
+
"@constructive-io/graphql-query": "^4.11.5",
|
|
60
|
+
"@constructive-io/graphql-types": "^3.27.2",
|
|
61
61
|
"@inquirerer/utils": "^3.3.9",
|
|
62
|
-
"@pgpmjs/core": "^7.
|
|
62
|
+
"@pgpmjs/core": "^7.21.0",
|
|
63
63
|
"ajv": "^8.20.0",
|
|
64
64
|
"deepmerge": "^4.3.1",
|
|
65
65
|
"find-and-require-package-json": "^0.9.1",
|
|
66
|
-
"gql-ast": "^3.22.
|
|
67
|
-
"graphile-schema": "^2.10.
|
|
66
|
+
"gql-ast": "^3.22.2",
|
|
67
|
+
"graphile-schema": "^2.10.5",
|
|
68
68
|
"graphql": "16.13.0",
|
|
69
69
|
"inflekt": "^0.7.1",
|
|
70
70
|
"inquirerer": "^4.9.1",
|
|
71
71
|
"jiti": "^2.7.0",
|
|
72
72
|
"oxfmt": "^0.51.0",
|
|
73
|
-
"pg-cache": "^3.24.
|
|
74
|
-
"pg-env": "^1.27.
|
|
75
|
-
"pgsql-client": "^4.9.
|
|
76
|
-
"pgsql-seed": "^3.9.
|
|
77
|
-
"query-spec": "^0.10.
|
|
73
|
+
"pg-cache": "^3.24.2",
|
|
74
|
+
"pg-env": "^1.27.2",
|
|
75
|
+
"pgsql-client": "^4.9.5",
|
|
76
|
+
"pgsql-seed": "^3.9.5",
|
|
77
|
+
"query-spec": "^0.10.2",
|
|
78
78
|
"undici": "^8.3.0"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"tsx": "^4.21.0",
|
|
102
102
|
"typescript": "^5.9.3"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "7a37da1f5655c36813343f09c6efa62ca0d7a855"
|
|
105
105
|
}
|