graphile-settings 4.9.2 → 4.10.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/esm/plugins/PublicKeySignature.d.ts +11 -0
- package/esm/plugins/PublicKeySignature.js +184 -0
- package/esm/plugins/conflict-detector.d.ts +7 -0
- package/esm/plugins/conflict-detector.js +67 -0
- package/esm/plugins/custom-inflector.d.ts +9 -0
- package/esm/plugins/custom-inflector.js +394 -0
- package/esm/plugins/enable-all-filter-columns.d.ts +60 -0
- package/esm/plugins/enable-all-filter-columns.js +85 -0
- package/esm/plugins/index.d.ts +16 -4
- package/esm/plugins/index.js +25 -4
- package/esm/plugins/inflector-logger.d.ts +7 -0
- package/esm/plugins/inflector-logger.js +215 -0
- package/esm/plugins/many-to-many-preset.d.ts +62 -0
- package/esm/plugins/many-to-many-preset.js +86 -0
- package/esm/plugins/meta-schema/cache.d.ts +4 -0
- package/esm/plugins/meta-schema/cache.js +7 -0
- package/esm/plugins/meta-schema/constraint-meta-builders.d.ts +13 -0
- package/esm/plugins/meta-schema/constraint-meta-builders.js +51 -0
- package/esm/plugins/meta-schema/graphql-meta-field.d.ts +4 -0
- package/esm/plugins/meta-schema/graphql-meta-field.js +201 -0
- package/esm/plugins/meta-schema/inflection-utils.d.ts +4 -0
- package/esm/plugins/meta-schema/inflection-utils.js +20 -0
- package/esm/plugins/meta-schema/name-meta-builders.d.ts +4 -0
- package/esm/plugins/meta-schema/name-meta-builders.js +38 -0
- package/esm/plugins/meta-schema/plugin.d.ts +2 -0
- package/esm/plugins/meta-schema/plugin.js +23 -0
- package/esm/plugins/meta-schema/relation-meta-builders.d.ts +8 -0
- package/esm/plugins/meta-schema/relation-meta-builders.js +115 -0
- package/esm/plugins/meta-schema/table-meta-builder.d.ts +2 -0
- package/esm/plugins/meta-schema/table-meta-builder.js +69 -0
- package/esm/plugins/meta-schema/table-meta-context.d.ts +13 -0
- package/esm/plugins/meta-schema/table-meta-context.js +11 -0
- package/esm/plugins/meta-schema/table-resource-utils.d.ts +12 -0
- package/esm/plugins/meta-schema/table-resource-utils.js +50 -0
- package/esm/plugins/meta-schema/type-mappings.d.ts +3 -0
- package/esm/plugins/meta-schema/type-mappings.js +75 -0
- package/esm/plugins/meta-schema/types.d.ts +206 -0
- package/esm/plugins/meta-schema/types.js +1 -0
- package/esm/plugins/meta-schema.d.ts +19 -0
- package/esm/plugins/meta-schema.js +20 -0
- package/esm/plugins/minimal-preset.d.ts +7 -0
- package/esm/plugins/minimal-preset.js +42 -0
- package/esm/plugins/pg-type-mappings.d.ts +41 -0
- package/esm/plugins/pg-type-mappings.js +122 -0
- package/esm/plugins/primary-key-only.d.ts +96 -0
- package/esm/plugins/primary-key-only.js +143 -0
- package/esm/plugins/required-input-plugin.d.ts +37 -0
- package/esm/plugins/required-input-plugin.js +88 -0
- package/esm/presets/constructive-preset.js +2 -1
- package/package.json +11 -9
- package/plugins/PublicKeySignature.d.ts +11 -0
- package/plugins/PublicKeySignature.js +191 -0
- package/plugins/conflict-detector.d.ts +7 -0
- package/plugins/conflict-detector.js +70 -0
- package/plugins/custom-inflector.d.ts +9 -0
- package/plugins/custom-inflector.js +397 -0
- package/plugins/enable-all-filter-columns.d.ts +60 -0
- package/plugins/enable-all-filter-columns.js +88 -0
- package/plugins/index.d.ts +16 -4
- package/plugins/index.js +54 -31
- package/plugins/inflector-logger.d.ts +7 -0
- package/plugins/inflector-logger.js +218 -0
- package/plugins/many-to-many-preset.d.ts +62 -0
- package/plugins/many-to-many-preset.js +89 -0
- package/plugins/meta-schema/cache.d.ts +4 -0
- package/plugins/meta-schema/cache.js +12 -0
- package/plugins/meta-schema/constraint-meta-builders.d.ts +13 -0
- package/plugins/meta-schema/constraint-meta-builders.js +58 -0
- package/plugins/meta-schema/graphql-meta-field.d.ts +4 -0
- package/plugins/meta-schema/graphql-meta-field.js +204 -0
- package/plugins/meta-schema/inflection-utils.d.ts +4 -0
- package/plugins/meta-schema/inflection-utils.js +25 -0
- package/plugins/meta-schema/name-meta-builders.d.ts +4 -0
- package/plugins/meta-schema/name-meta-builders.js +43 -0
- package/plugins/meta-schema/plugin.d.ts +2 -0
- package/plugins/meta-schema/plugin.js +26 -0
- package/plugins/meta-schema/relation-meta-builders.d.ts +8 -0
- package/plugins/meta-schema/relation-meta-builders.js +120 -0
- package/plugins/meta-schema/table-meta-builder.d.ts +2 -0
- package/plugins/meta-schema/table-meta-builder.js +72 -0
- package/plugins/meta-schema/table-meta-context.d.ts +13 -0
- package/plugins/meta-schema/table-meta-context.js +15 -0
- package/plugins/meta-schema/table-resource-utils.d.ts +12 -0
- package/plugins/meta-schema/table-resource-utils.js +60 -0
- package/plugins/meta-schema/type-mappings.d.ts +3 -0
- package/plugins/meta-schema/type-mappings.js +79 -0
- package/plugins/meta-schema/types.d.ts +206 -0
- package/plugins/meta-schema/types.js +2 -0
- package/plugins/meta-schema.d.ts +19 -0
- package/plugins/meta-schema.js +20 -0
- package/plugins/minimal-preset.d.ts +7 -0
- package/plugins/minimal-preset.js +45 -0
- package/plugins/pg-type-mappings.d.ts +41 -0
- package/plugins/pg-type-mappings.js +128 -0
- package/plugins/primary-key-only.d.ts +96 -0
- package/plugins/primary-key-only.js +147 -0
- package/plugins/required-input-plugin.d.ts +37 -0
- package/plugins/required-input-plugin.js +91 -0
- package/presets/constructive-preset.js +11 -10
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.extendQueryWithMetaField = extendQueryWithMetaField;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
function nn(type) {
|
|
6
|
+
return new graphql_1.GraphQLNonNull(type);
|
|
7
|
+
}
|
|
8
|
+
function nnList(type) {
|
|
9
|
+
return nn(new graphql_1.GraphQLList(nn(type)));
|
|
10
|
+
}
|
|
11
|
+
function createMetaSchemaType() {
|
|
12
|
+
const MetaTypeType = new graphql_1.GraphQLObjectType({
|
|
13
|
+
name: 'MetaType',
|
|
14
|
+
description: 'Information about a PostgreSQL type',
|
|
15
|
+
fields: () => ({
|
|
16
|
+
pgType: { type: nn(graphql_1.GraphQLString) },
|
|
17
|
+
gqlType: { type: nn(graphql_1.GraphQLString) },
|
|
18
|
+
isArray: { type: nn(graphql_1.GraphQLBoolean) },
|
|
19
|
+
isNotNull: { type: graphql_1.GraphQLBoolean },
|
|
20
|
+
hasDefault: { type: graphql_1.GraphQLBoolean },
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
const MetaFieldType = new graphql_1.GraphQLObjectType({
|
|
24
|
+
name: 'MetaField',
|
|
25
|
+
description: 'Information about a table field/column',
|
|
26
|
+
fields: () => ({
|
|
27
|
+
name: { type: nn(graphql_1.GraphQLString) },
|
|
28
|
+
type: { type: nn(MetaTypeType) },
|
|
29
|
+
isNotNull: { type: nn(graphql_1.GraphQLBoolean) },
|
|
30
|
+
hasDefault: { type: nn(graphql_1.GraphQLBoolean) },
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
const MetaIndexType = new graphql_1.GraphQLObjectType({
|
|
34
|
+
name: 'MetaIndex',
|
|
35
|
+
description: 'Information about a database index',
|
|
36
|
+
fields: () => ({
|
|
37
|
+
name: { type: nn(graphql_1.GraphQLString) },
|
|
38
|
+
isUnique: { type: nn(graphql_1.GraphQLBoolean) },
|
|
39
|
+
isPrimary: { type: nn(graphql_1.GraphQLBoolean) },
|
|
40
|
+
columns: { type: nnList(graphql_1.GraphQLString) },
|
|
41
|
+
fields: { type: new graphql_1.GraphQLList(nn(MetaFieldType)) },
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
const MetaPrimaryKeyConstraintType = new graphql_1.GraphQLObjectType({
|
|
45
|
+
name: 'MetaPrimaryKeyConstraint',
|
|
46
|
+
description: 'Information about a primary key constraint',
|
|
47
|
+
fields: () => ({
|
|
48
|
+
name: { type: nn(graphql_1.GraphQLString) },
|
|
49
|
+
fields: { type: nnList(MetaFieldType) },
|
|
50
|
+
}),
|
|
51
|
+
});
|
|
52
|
+
const MetaUniqueConstraintType = new graphql_1.GraphQLObjectType({
|
|
53
|
+
name: 'MetaUniqueConstraint',
|
|
54
|
+
description: 'Information about a unique constraint',
|
|
55
|
+
fields: () => ({
|
|
56
|
+
name: { type: nn(graphql_1.GraphQLString) },
|
|
57
|
+
fields: { type: nnList(MetaFieldType) },
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
const MetaRefTableType = new graphql_1.GraphQLObjectType({
|
|
61
|
+
name: 'MetaRefTable',
|
|
62
|
+
description: 'Reference to a related table',
|
|
63
|
+
fields: () => ({
|
|
64
|
+
name: { type: nn(graphql_1.GraphQLString) },
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
const MetaForeignKeyConstraintType = new graphql_1.GraphQLObjectType({
|
|
68
|
+
name: 'MetaForeignKeyConstraint',
|
|
69
|
+
description: 'Information about a foreign key constraint',
|
|
70
|
+
fields: () => ({
|
|
71
|
+
name: { type: nn(graphql_1.GraphQLString) },
|
|
72
|
+
fields: { type: nnList(MetaFieldType) },
|
|
73
|
+
referencedTable: { type: nn(graphql_1.GraphQLString) },
|
|
74
|
+
referencedFields: { type: nnList(graphql_1.GraphQLString) },
|
|
75
|
+
refFields: { type: new graphql_1.GraphQLList(nn(MetaFieldType)) },
|
|
76
|
+
refTable: { type: MetaRefTableType },
|
|
77
|
+
}),
|
|
78
|
+
});
|
|
79
|
+
const MetaConstraintsType = new graphql_1.GraphQLObjectType({
|
|
80
|
+
name: 'MetaConstraints',
|
|
81
|
+
description: 'Table constraints',
|
|
82
|
+
fields: () => ({
|
|
83
|
+
primaryKey: { type: MetaPrimaryKeyConstraintType },
|
|
84
|
+
unique: { type: nnList(MetaUniqueConstraintType) },
|
|
85
|
+
foreignKey: { type: nnList(MetaForeignKeyConstraintType) },
|
|
86
|
+
}),
|
|
87
|
+
});
|
|
88
|
+
const MetaInflectionType = new graphql_1.GraphQLObjectType({
|
|
89
|
+
name: 'MetaInflection',
|
|
90
|
+
description: 'Table inflection names',
|
|
91
|
+
fields: () => ({
|
|
92
|
+
tableType: { type: nn(graphql_1.GraphQLString) },
|
|
93
|
+
allRows: { type: nn(graphql_1.GraphQLString) },
|
|
94
|
+
connection: { type: nn(graphql_1.GraphQLString) },
|
|
95
|
+
edge: { type: nn(graphql_1.GraphQLString) },
|
|
96
|
+
filterType: { type: graphql_1.GraphQLString },
|
|
97
|
+
orderByType: { type: nn(graphql_1.GraphQLString) },
|
|
98
|
+
conditionType: { type: nn(graphql_1.GraphQLString) },
|
|
99
|
+
patchType: { type: graphql_1.GraphQLString },
|
|
100
|
+
createInputType: { type: nn(graphql_1.GraphQLString) },
|
|
101
|
+
createPayloadType: { type: nn(graphql_1.GraphQLString) },
|
|
102
|
+
updatePayloadType: { type: graphql_1.GraphQLString },
|
|
103
|
+
deletePayloadType: { type: nn(graphql_1.GraphQLString) },
|
|
104
|
+
}),
|
|
105
|
+
});
|
|
106
|
+
const MetaQueryType = new graphql_1.GraphQLObjectType({
|
|
107
|
+
name: 'MetaQuery',
|
|
108
|
+
description: 'Table query/mutation names',
|
|
109
|
+
fields: () => ({
|
|
110
|
+
all: { type: nn(graphql_1.GraphQLString) },
|
|
111
|
+
one: { type: graphql_1.GraphQLString },
|
|
112
|
+
create: { type: graphql_1.GraphQLString },
|
|
113
|
+
update: { type: graphql_1.GraphQLString },
|
|
114
|
+
delete: { type: graphql_1.GraphQLString },
|
|
115
|
+
}),
|
|
116
|
+
});
|
|
117
|
+
const MetaBelongsToRelationType = new graphql_1.GraphQLObjectType({
|
|
118
|
+
name: 'MetaBelongsToRelation',
|
|
119
|
+
description: 'A belongs-to (forward FK) relation',
|
|
120
|
+
fields: () => ({
|
|
121
|
+
fieldName: { type: graphql_1.GraphQLString },
|
|
122
|
+
isUnique: { type: nn(graphql_1.GraphQLBoolean) },
|
|
123
|
+
type: { type: graphql_1.GraphQLString },
|
|
124
|
+
keys: { type: nnList(MetaFieldType) },
|
|
125
|
+
references: { type: nn(MetaRefTableType) },
|
|
126
|
+
}),
|
|
127
|
+
});
|
|
128
|
+
const MetaHasRelationType = new graphql_1.GraphQLObjectType({
|
|
129
|
+
name: 'MetaHasRelation',
|
|
130
|
+
description: 'A has-one or has-many (reverse FK) relation',
|
|
131
|
+
fields: () => ({
|
|
132
|
+
fieldName: { type: graphql_1.GraphQLString },
|
|
133
|
+
isUnique: { type: nn(graphql_1.GraphQLBoolean) },
|
|
134
|
+
type: { type: graphql_1.GraphQLString },
|
|
135
|
+
keys: { type: nnList(MetaFieldType) },
|
|
136
|
+
referencedBy: { type: nn(MetaRefTableType) },
|
|
137
|
+
}),
|
|
138
|
+
});
|
|
139
|
+
const MetaManyToManyRelationType = new graphql_1.GraphQLObjectType({
|
|
140
|
+
name: 'MetaManyToManyRelation',
|
|
141
|
+
description: 'A many-to-many relation via junction table',
|
|
142
|
+
fields: () => ({
|
|
143
|
+
fieldName: { type: graphql_1.GraphQLString },
|
|
144
|
+
type: { type: graphql_1.GraphQLString },
|
|
145
|
+
junctionTable: { type: nn(MetaRefTableType) },
|
|
146
|
+
junctionLeftConstraint: { type: nn(MetaForeignKeyConstraintType) },
|
|
147
|
+
junctionLeftKeyAttributes: { type: nnList(MetaFieldType) },
|
|
148
|
+
junctionRightConstraint: { type: nn(MetaForeignKeyConstraintType) },
|
|
149
|
+
junctionRightKeyAttributes: { type: nnList(MetaFieldType) },
|
|
150
|
+
leftKeyAttributes: { type: nnList(MetaFieldType) },
|
|
151
|
+
rightKeyAttributes: { type: nnList(MetaFieldType) },
|
|
152
|
+
rightTable: { type: nn(MetaRefTableType) },
|
|
153
|
+
}),
|
|
154
|
+
});
|
|
155
|
+
const MetaRelationsType = new graphql_1.GraphQLObjectType({
|
|
156
|
+
name: 'MetaRelations',
|
|
157
|
+
description: 'Table relations',
|
|
158
|
+
fields: () => ({
|
|
159
|
+
belongsTo: { type: nnList(MetaBelongsToRelationType) },
|
|
160
|
+
has: { type: nnList(MetaHasRelationType) },
|
|
161
|
+
hasOne: { type: nnList(MetaHasRelationType) },
|
|
162
|
+
hasMany: { type: nnList(MetaHasRelationType) },
|
|
163
|
+
manyToMany: { type: nnList(MetaManyToManyRelationType) },
|
|
164
|
+
}),
|
|
165
|
+
});
|
|
166
|
+
const MetaTableType = new graphql_1.GraphQLObjectType({
|
|
167
|
+
name: 'MetaTable',
|
|
168
|
+
description: 'Information about a database table',
|
|
169
|
+
fields: () => ({
|
|
170
|
+
name: { type: nn(graphql_1.GraphQLString) },
|
|
171
|
+
schemaName: { type: nn(graphql_1.GraphQLString) },
|
|
172
|
+
fields: { type: nnList(MetaFieldType) },
|
|
173
|
+
indexes: { type: nnList(MetaIndexType) },
|
|
174
|
+
constraints: { type: nn(MetaConstraintsType) },
|
|
175
|
+
foreignKeyConstraints: { type: nnList(MetaForeignKeyConstraintType) },
|
|
176
|
+
primaryKeyConstraints: { type: nnList(MetaPrimaryKeyConstraintType) },
|
|
177
|
+
uniqueConstraints: { type: nnList(MetaUniqueConstraintType) },
|
|
178
|
+
relations: { type: nn(MetaRelationsType) },
|
|
179
|
+
inflection: { type: nn(MetaInflectionType) },
|
|
180
|
+
query: { type: nn(MetaQueryType) },
|
|
181
|
+
}),
|
|
182
|
+
});
|
|
183
|
+
return new graphql_1.GraphQLObjectType({
|
|
184
|
+
name: 'MetaSchema',
|
|
185
|
+
description: 'Root meta schema type',
|
|
186
|
+
fields: () => ({
|
|
187
|
+
tables: { type: nnList(MetaTableType) },
|
|
188
|
+
}),
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function extendQueryWithMetaField(fields, tablesMeta) {
|
|
192
|
+
const metaSchemaType = createMetaSchemaType();
|
|
193
|
+
const metaField = {
|
|
194
|
+
type: metaSchemaType,
|
|
195
|
+
description: 'Metadata about the database schema, including tables, fields, indexes, and constraints. Useful for code generation tools.',
|
|
196
|
+
resolve() {
|
|
197
|
+
return { tables: tablesMeta };
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
return {
|
|
201
|
+
...fields,
|
|
202
|
+
_meta: metaField,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MetaInflection, PgCodec } from './types';
|
|
2
|
+
export declare function safeInflection<T>(fn: () => T, fallback: T): T;
|
|
3
|
+
export declare function createAttributeInflector(inflection: MetaInflection): (attrName: string, codec: PgCodec) => string;
|
|
4
|
+
export declare function fallbackTableType(codecName: string): string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.safeInflection = safeInflection;
|
|
4
|
+
exports.createAttributeInflector = createAttributeInflector;
|
|
5
|
+
exports.fallbackTableType = fallbackTableType;
|
|
6
|
+
function safeInflection(fn, fallback) {
|
|
7
|
+
try {
|
|
8
|
+
return fn() ?? fallback;
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return fallback;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function createAttributeInflector(inflection) {
|
|
15
|
+
return (attrName, codec) => {
|
|
16
|
+
const attributeName = safeInflection(() => inflection._attributeName?.({ attributeName: attrName, codec }), attrName);
|
|
17
|
+
return safeInflection(() => inflection.camelCase?.(attributeName), attributeName);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function fallbackTableType(codecName) {
|
|
21
|
+
return codecName
|
|
22
|
+
.replace(/_/g, ' ')
|
|
23
|
+
.replace(/\b\w/g, (char) => char.toUpperCase())
|
|
24
|
+
.replace(/ /g, '');
|
|
25
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { InflectionMeta, MetaBuild, PgCodec, PgTableResource, PgUnique, QueryMeta } from './types';
|
|
2
|
+
export declare function resolveTableType(build: MetaBuild, codec: PgCodec): string;
|
|
3
|
+
export declare function buildInflectionMeta(resource: PgTableResource, tableType: string, build: MetaBuild): InflectionMeta;
|
|
4
|
+
export declare function buildQueryMeta(resource: PgTableResource, uniques: PgUnique[], tableType: string, build: MetaBuild): QueryMeta;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveTableType = resolveTableType;
|
|
4
|
+
exports.buildInflectionMeta = buildInflectionMeta;
|
|
5
|
+
exports.buildQueryMeta = buildQueryMeta;
|
|
6
|
+
const inflection_utils_1 = require("./inflection-utils");
|
|
7
|
+
function resolveTableType(build, codec) {
|
|
8
|
+
return (0, inflection_utils_1.safeInflection)(() => build.inflection.tableType(codec), (0, inflection_utils_1.fallbackTableType)(codec.name));
|
|
9
|
+
}
|
|
10
|
+
function buildInflectionMeta(resource, tableType, build) {
|
|
11
|
+
const inflection = build.inflection;
|
|
12
|
+
return {
|
|
13
|
+
tableType,
|
|
14
|
+
allRows: (0, inflection_utils_1.safeInflection)(() => inflection.allRows?.(resource), `${tableType.toLowerCase()}s`),
|
|
15
|
+
connection: (0, inflection_utils_1.safeInflection)(() => inflection.connectionType?.(tableType), `${tableType}Connection`),
|
|
16
|
+
edge: (0, inflection_utils_1.safeInflection)(() => inflection.edgeType?.(tableType), `${tableType}Edge`),
|
|
17
|
+
filterType: (0, inflection_utils_1.safeInflection)(() => inflection.filterType?.(tableType), `${tableType}Filter`),
|
|
18
|
+
orderByType: (0, inflection_utils_1.safeInflection)(() => inflection.orderByType?.(tableType), `${tableType}OrderBy`),
|
|
19
|
+
conditionType: (0, inflection_utils_1.safeInflection)(() => inflection.conditionType?.(tableType), `${tableType}Condition`),
|
|
20
|
+
patchType: (0, inflection_utils_1.safeInflection)(() => inflection.patchType?.(tableType), `${tableType}Patch`),
|
|
21
|
+
createInputType: (0, inflection_utils_1.safeInflection)(() => inflection.createInputType?.(resource), `Create${tableType}Input`),
|
|
22
|
+
createPayloadType: (0, inflection_utils_1.safeInflection)(() => inflection.createPayloadType?.(resource), `Create${tableType}Payload`),
|
|
23
|
+
updatePayloadType: (0, inflection_utils_1.safeInflection)(() => inflection.updatePayloadType?.(resource), `Update${tableType}Payload`),
|
|
24
|
+
deletePayloadType: (0, inflection_utils_1.safeInflection)(() => inflection.deletePayloadType?.(resource), `Delete${tableType}Payload`),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function buildQueryMeta(resource, uniques, tableType, build) {
|
|
28
|
+
const inflection = build.inflection;
|
|
29
|
+
const hasPrimaryKey = uniques.some((unique) => unique.isPrimary);
|
|
30
|
+
return {
|
|
31
|
+
all: (0, inflection_utils_1.safeInflection)(() => inflection.allRows?.(resource), `${tableType.toLowerCase()}s`),
|
|
32
|
+
one: hasPrimaryKey
|
|
33
|
+
? (0, inflection_utils_1.safeInflection)(() => inflection.tableFieldName?.(resource), tableType.toLowerCase())
|
|
34
|
+
: null,
|
|
35
|
+
create: (0, inflection_utils_1.safeInflection)(() => inflection.createField?.(resource), `create${tableType}`),
|
|
36
|
+
update: hasPrimaryKey
|
|
37
|
+
? (0, inflection_utils_1.safeInflection)(() => inflection.updateByKeys?.(resource), `update${tableType}`)
|
|
38
|
+
: null,
|
|
39
|
+
delete: hasPrimaryKey
|
|
40
|
+
? (0, inflection_utils_1.safeInflection)(() => inflection.deleteByKeys?.(resource), `delete${tableType}`)
|
|
41
|
+
: null,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetaSchemaPlugin = void 0;
|
|
4
|
+
const cache_1 = require("./cache");
|
|
5
|
+
const graphql_meta_field_1 = require("./graphql-meta-field");
|
|
6
|
+
const table_meta_builder_1 = require("./table-meta-builder");
|
|
7
|
+
exports.MetaSchemaPlugin = {
|
|
8
|
+
name: 'MetaSchemaPlugin',
|
|
9
|
+
version: '1.0.0',
|
|
10
|
+
description: 'Exposes _meta query for database schema introspection',
|
|
11
|
+
schema: {
|
|
12
|
+
hooks: {
|
|
13
|
+
init(input, rawBuild) {
|
|
14
|
+
const build = rawBuild;
|
|
15
|
+
(0, cache_1.setCachedTablesMeta)((0, table_meta_builder_1.collectTablesMeta)(build));
|
|
16
|
+
return input;
|
|
17
|
+
},
|
|
18
|
+
GraphQLObjectType_fields(rawFields, _rawBuild, rawContext) {
|
|
19
|
+
const context = rawContext;
|
|
20
|
+
if (context.Self?.name !== 'Query')
|
|
21
|
+
return rawFields;
|
|
22
|
+
return (0, graphql_meta_field_1.extendQueryWithMetaField)(rawFields, (0, cache_1.getCachedTablesMeta)());
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type BuildContext } from './table-meta-context';
|
|
2
|
+
import type { BelongsToRelation, HasRelation, ManyToManyRelation, PgAttribute, PgCodec, PgRelation, PgTableResource, PgUnique } from './types';
|
|
3
|
+
export declare function buildBelongsToRelations(codec: PgCodec, attributes: Record<string, PgAttribute>, uniques: PgUnique[], relations: Record<string, PgRelation>, context: BuildContext): BelongsToRelation[];
|
|
4
|
+
export declare function buildReverseRelations(codec: PgCodec, attributes: Record<string, PgAttribute>, relations: Record<string, PgRelation>, context: BuildContext): {
|
|
5
|
+
hasOne: HasRelation[];
|
|
6
|
+
hasMany: HasRelation[];
|
|
7
|
+
};
|
|
8
|
+
export declare function buildManyToManyRelations(resource: PgTableResource, codec: PgCodec, context: BuildContext): ManyToManyRelation[];
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildBelongsToRelations = buildBelongsToRelations;
|
|
4
|
+
exports.buildReverseRelations = buildReverseRelations;
|
|
5
|
+
exports.buildManyToManyRelations = buildManyToManyRelations;
|
|
6
|
+
const inflection_utils_1 = require("./inflection-utils");
|
|
7
|
+
const constraint_meta_builders_1 = require("./constraint-meta-builders");
|
|
8
|
+
const table_meta_context_1 = require("./table-meta-context");
|
|
9
|
+
const table_resource_utils_1 = require("./table-resource-utils");
|
|
10
|
+
function isRecord(value) {
|
|
11
|
+
return typeof value === 'object' && value !== null;
|
|
12
|
+
}
|
|
13
|
+
function buildBelongsToRelations(codec, attributes, uniques, relations, context) {
|
|
14
|
+
const belongsTo = [];
|
|
15
|
+
for (const [relationName, relation] of Object.entries(relations)) {
|
|
16
|
+
if (relation.isReferencee !== false)
|
|
17
|
+
continue;
|
|
18
|
+
const localAttributes = relation.localAttributes || [];
|
|
19
|
+
const isUnique = uniques.some((unique) => (0, table_resource_utils_1.sameAttributes)(unique.attributes, localAttributes));
|
|
20
|
+
belongsTo.push({
|
|
21
|
+
fieldName: relationName,
|
|
22
|
+
isUnique,
|
|
23
|
+
type: relation.remoteResource?.codec?.name || null,
|
|
24
|
+
keys: (0, table_meta_context_1.buildFieldList)(localAttributes, codec, attributes, context),
|
|
25
|
+
references: { name: relation.remoteResource?.codec?.name || 'unknown' },
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return belongsTo;
|
|
29
|
+
}
|
|
30
|
+
function buildReverseRelations(codec, attributes, relations, context) {
|
|
31
|
+
const hasOne = [];
|
|
32
|
+
const hasMany = [];
|
|
33
|
+
for (const [relationName, relation] of Object.entries(relations)) {
|
|
34
|
+
if (relation.isReferencee !== true)
|
|
35
|
+
continue;
|
|
36
|
+
const remoteUniques = (0, table_resource_utils_1.getUniques)(relation.remoteResource || {});
|
|
37
|
+
const remoteAttributes = relation.remoteAttributes || [];
|
|
38
|
+
const isUnique = remoteUniques.some((unique) => (0, table_resource_utils_1.sameAttributes)(unique.attributes, remoteAttributes));
|
|
39
|
+
const meta = {
|
|
40
|
+
fieldName: relationName,
|
|
41
|
+
isUnique,
|
|
42
|
+
type: relation.remoteResource?.codec?.name || null,
|
|
43
|
+
keys: (0, table_meta_context_1.buildFieldList)(relation.localAttributes || [], codec, attributes, context),
|
|
44
|
+
referencedBy: { name: relation.remoteResource?.codec?.name || 'unknown' },
|
|
45
|
+
};
|
|
46
|
+
if (isUnique) {
|
|
47
|
+
hasOne.push(meta);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
hasMany.push(meta);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return { hasOne, hasMany };
|
|
54
|
+
}
|
|
55
|
+
function isManyToManyDetails(value) {
|
|
56
|
+
if (!isRecord(value))
|
|
57
|
+
return false;
|
|
58
|
+
return (isRecord(value.leftTable) &&
|
|
59
|
+
isRecord(value.junctionTable) &&
|
|
60
|
+
isRecord(value.rightTable) &&
|
|
61
|
+
typeof value.leftRelationName === 'string' &&
|
|
62
|
+
typeof value.rightRelationName === 'string');
|
|
63
|
+
}
|
|
64
|
+
function parseManyToManyRelationships(value) {
|
|
65
|
+
if (!Array.isArray(value))
|
|
66
|
+
return [];
|
|
67
|
+
return value.filter(isManyToManyDetails);
|
|
68
|
+
}
|
|
69
|
+
function getManyToManyRelationships(build, tableResource, codec) {
|
|
70
|
+
const relationshipsByResource = build.pgManyToManyRealtionshipsByResource;
|
|
71
|
+
if (!(relationshipsByResource instanceof Map))
|
|
72
|
+
return [];
|
|
73
|
+
const direct = parseManyToManyRelationships(relationshipsByResource.get(tableResource));
|
|
74
|
+
if (direct.length > 0)
|
|
75
|
+
return direct;
|
|
76
|
+
for (const [leftTable, relationships] of relationshipsByResource.entries()) {
|
|
77
|
+
const details = parseManyToManyRelationships(relationships);
|
|
78
|
+
if (details.length === 0 || !isRecord(leftTable))
|
|
79
|
+
continue;
|
|
80
|
+
if (leftTable.codec === codec) {
|
|
81
|
+
return details;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
function buildManyToManyRelation(details, context) {
|
|
87
|
+
const leftCodec = (0, table_resource_utils_1.getResourceCodec)(details.leftTable);
|
|
88
|
+
const junctionCodec = (0, table_resource_utils_1.getResourceCodec)(details.junctionTable);
|
|
89
|
+
const rightCodec = (0, table_resource_utils_1.getResourceCodec)(details.rightTable);
|
|
90
|
+
if (!leftCodec || !junctionCodec || !rightCodec)
|
|
91
|
+
return null;
|
|
92
|
+
const leftRelation = (0, table_resource_utils_1.getRelation)(details.leftTable, details.leftRelationName);
|
|
93
|
+
const junctionRightRelation = (0, table_resource_utils_1.getRelation)(details.junctionTable, details.rightRelationName);
|
|
94
|
+
if (!leftRelation || !junctionRightRelation)
|
|
95
|
+
return null;
|
|
96
|
+
const leftJunctionAttributes = leftRelation.remoteAttributes || [];
|
|
97
|
+
const leftTableAttributes = leftRelation.localAttributes || [];
|
|
98
|
+
const rightJunctionAttributes = junctionRightRelation.localAttributes || [];
|
|
99
|
+
const rightTableAttributes = junctionRightRelation.remoteAttributes || [];
|
|
100
|
+
const relationFieldName = (0, inflection_utils_1.safeInflection)(() => context.build.inflection._manyToManyRelation?.(details), details.rightRelationName || rightCodec.name || null);
|
|
101
|
+
const junctionLeftConstraint = (0, constraint_meta_builders_1.buildForeignKeyConstraint)(details.leftRelationName || `${junctionCodec.name}_${leftCodec.name}_fkey`, junctionCodec, junctionCodec.attributes, leftJunctionAttributes, leftCodec, leftCodec.attributes, leftTableAttributes, context);
|
|
102
|
+
const junctionRightConstraint = (0, constraint_meta_builders_1.buildForeignKeyConstraint)(details.rightRelationName || `${junctionCodec.name}_${rightCodec.name}_fkey`, junctionCodec, junctionCodec.attributes, rightJunctionAttributes, rightCodec, rightCodec.attributes, rightTableAttributes, context);
|
|
103
|
+
return {
|
|
104
|
+
fieldName: relationFieldName,
|
|
105
|
+
type: rightCodec.name || null,
|
|
106
|
+
junctionTable: { name: junctionCodec.name || 'unknown' },
|
|
107
|
+
junctionLeftConstraint,
|
|
108
|
+
junctionLeftKeyAttributes: (0, table_meta_context_1.buildFieldList)(leftJunctionAttributes, junctionCodec, junctionCodec.attributes, context),
|
|
109
|
+
junctionRightConstraint,
|
|
110
|
+
junctionRightKeyAttributes: (0, table_meta_context_1.buildFieldList)(rightJunctionAttributes, junctionCodec, junctionCodec.attributes, context),
|
|
111
|
+
leftKeyAttributes: (0, table_meta_context_1.buildFieldList)(leftTableAttributes, leftCodec, leftCodec.attributes, context),
|
|
112
|
+
rightKeyAttributes: (0, table_meta_context_1.buildFieldList)(rightTableAttributes, rightCodec, rightCodec.attributes, context),
|
|
113
|
+
rightTable: { name: rightCodec.name || 'unknown' },
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function buildManyToManyRelations(resource, codec, context) {
|
|
117
|
+
return getManyToManyRelationships(context.build, resource, codec)
|
|
118
|
+
.map((details) => buildManyToManyRelation(details, context))
|
|
119
|
+
.filter((relation) => relation !== null);
|
|
120
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectTablesMeta = collectTablesMeta;
|
|
4
|
+
const constraint_meta_builders_1 = require("./constraint-meta-builders");
|
|
5
|
+
const name_meta_builders_1 = require("./name-meta-builders");
|
|
6
|
+
const relation_meta_builders_1 = require("./relation-meta-builders");
|
|
7
|
+
const type_mappings_1 = require("./type-mappings");
|
|
8
|
+
const table_meta_context_1 = require("./table-meta-context");
|
|
9
|
+
const table_resource_utils_1 = require("./table-resource-utils");
|
|
10
|
+
function buildTableMeta(resource, schemaName, context) {
|
|
11
|
+
const codec = resource.codec;
|
|
12
|
+
const attributes = codec.attributes;
|
|
13
|
+
const uniques = (0, table_resource_utils_1.getUniques)(resource);
|
|
14
|
+
const relations = (0, table_resource_utils_1.getRelations)(resource);
|
|
15
|
+
const fields = Object.entries(attributes).map(([attrName, attr]) => (0, type_mappings_1.buildFieldMeta)(context.inflectAttr(attrName, codec), attr, context.build));
|
|
16
|
+
const indexes = (0, constraint_meta_builders_1.buildIndexes)(codec, attributes, uniques, context);
|
|
17
|
+
const primaryKey = (0, constraint_meta_builders_1.buildPrimaryKey)(codec, attributes, uniques, context);
|
|
18
|
+
const uniqueConstraints = (0, constraint_meta_builders_1.buildUniqueConstraints)(codec, attributes, uniques, context);
|
|
19
|
+
const foreignKeyConstraints = (0, constraint_meta_builders_1.buildForeignKeyConstraints)(codec, attributes, relations, context);
|
|
20
|
+
const constraints = {
|
|
21
|
+
primaryKey,
|
|
22
|
+
unique: uniqueConstraints,
|
|
23
|
+
foreignKey: foreignKeyConstraints,
|
|
24
|
+
};
|
|
25
|
+
const belongsTo = (0, relation_meta_builders_1.buildBelongsToRelations)(codec, attributes, uniques, relations, context);
|
|
26
|
+
const { hasOne, hasMany } = (0, relation_meta_builders_1.buildReverseRelations)(codec, attributes, relations, context);
|
|
27
|
+
const manyToMany = (0, relation_meta_builders_1.buildManyToManyRelations)(resource, codec, context);
|
|
28
|
+
const relationsMeta = {
|
|
29
|
+
belongsTo,
|
|
30
|
+
has: [...hasOne, ...hasMany],
|
|
31
|
+
hasOne,
|
|
32
|
+
hasMany,
|
|
33
|
+
manyToMany,
|
|
34
|
+
};
|
|
35
|
+
const tableType = (0, name_meta_builders_1.resolveTableType)(context.build, codec);
|
|
36
|
+
return {
|
|
37
|
+
name: tableType,
|
|
38
|
+
schemaName,
|
|
39
|
+
fields,
|
|
40
|
+
indexes,
|
|
41
|
+
constraints,
|
|
42
|
+
foreignKeyConstraints,
|
|
43
|
+
primaryKeyConstraints: primaryKey ? [primaryKey] : [],
|
|
44
|
+
uniqueConstraints,
|
|
45
|
+
relations: relationsMeta,
|
|
46
|
+
inflection: (0, name_meta_builders_1.buildInflectionMeta)(resource, tableType, context.build),
|
|
47
|
+
query: (0, name_meta_builders_1.buildQueryMeta)(resource, uniques, tableType, context.build),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function collectTablesMeta(build) {
|
|
51
|
+
const configuredSchemas = (0, table_resource_utils_1.getConfiguredSchemas)(build);
|
|
52
|
+
const context = (0, table_meta_context_1.createBuildContext)(build);
|
|
53
|
+
const seenCodecs = new Set();
|
|
54
|
+
const tablesMeta = [];
|
|
55
|
+
for (const resource of Object.values(build.input.pgRegistry.pgResources || {})) {
|
|
56
|
+
if (!(0, table_resource_utils_1.isTableResource)(resource))
|
|
57
|
+
continue;
|
|
58
|
+
const codec = resource.codec;
|
|
59
|
+
if (seenCodecs.has(codec))
|
|
60
|
+
continue;
|
|
61
|
+
seenCodecs.add(codec);
|
|
62
|
+
const schemaName = (0, table_resource_utils_1.getSchemaName)(resource);
|
|
63
|
+
if (!schemaName)
|
|
64
|
+
continue;
|
|
65
|
+
if (configuredSchemas.length > 0 &&
|
|
66
|
+
!configuredSchemas.includes(schemaName)) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
tablesMeta.push(buildTableMeta(resource, schemaName, context));
|
|
70
|
+
}
|
|
71
|
+
return tablesMeta;
|
|
72
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FieldMeta, MetaBuild, PgAttribute, PgCodec, PgTableResource } from './types';
|
|
2
|
+
export type AttributeInflector = (attrName: string, codec: PgCodec) => string;
|
|
3
|
+
export interface BuildContext {
|
|
4
|
+
build: MetaBuild;
|
|
5
|
+
inflectAttr: AttributeInflector;
|
|
6
|
+
}
|
|
7
|
+
export type TableResourceWithCodec = PgTableResource & {
|
|
8
|
+
codec: PgCodec & {
|
|
9
|
+
attributes: Record<string, PgAttribute>;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export declare function createBuildContext(build: MetaBuild): BuildContext;
|
|
13
|
+
export declare function buildFieldList(attrNames: string[], codec: PgCodec, attributes: Record<string, PgAttribute>, context: BuildContext): FieldMeta[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createBuildContext = createBuildContext;
|
|
4
|
+
exports.buildFieldList = buildFieldList;
|
|
5
|
+
const inflection_utils_1 = require("./inflection-utils");
|
|
6
|
+
const type_mappings_1 = require("./type-mappings");
|
|
7
|
+
function createBuildContext(build) {
|
|
8
|
+
return {
|
|
9
|
+
build,
|
|
10
|
+
inflectAttr: (0, inflection_utils_1.createAttributeInflector)(build.inflection),
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function buildFieldList(attrNames, codec, attributes, context) {
|
|
14
|
+
return attrNames.map((attrName) => (0, type_mappings_1.buildFieldMeta)(context.inflectAttr(attrName, codec), attributes[attrName], context.build));
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MetaBuild, PgAttribute, PgCodec, PgRelation, PgTableResource, PgUnique } from './types';
|
|
2
|
+
import type { TableResourceWithCodec } from './table-meta-context';
|
|
3
|
+
export declare function isTableResource(resource: PgTableResource): resource is TableResourceWithCodec;
|
|
4
|
+
export declare function getSchemaName(resource: PgTableResource): string | null;
|
|
5
|
+
export declare function getUniques(resource: PgTableResource): PgUnique[];
|
|
6
|
+
export declare function getRelations(resource: PgTableResource): Record<string, PgRelation>;
|
|
7
|
+
export declare function getRelation(resource: PgTableResource, relationName: string): PgRelation | null;
|
|
8
|
+
export declare function sameAttributes(uniqueAttributes: string[] | undefined, relationAttributes: string[] | undefined): boolean;
|
|
9
|
+
export declare function getConfiguredSchemas(build: MetaBuild): string[];
|
|
10
|
+
export declare function getResourceCodec(resource: PgTableResource): (PgCodec & {
|
|
11
|
+
attributes: Record<string, PgAttribute>;
|
|
12
|
+
}) | null;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isTableResource = isTableResource;
|
|
4
|
+
exports.getSchemaName = getSchemaName;
|
|
5
|
+
exports.getUniques = getUniques;
|
|
6
|
+
exports.getRelations = getRelations;
|
|
7
|
+
exports.getRelation = getRelation;
|
|
8
|
+
exports.sameAttributes = sameAttributes;
|
|
9
|
+
exports.getConfiguredSchemas = getConfiguredSchemas;
|
|
10
|
+
exports.getResourceCodec = getResourceCodec;
|
|
11
|
+
function isRecord(value) {
|
|
12
|
+
return typeof value === 'object' && value !== null;
|
|
13
|
+
}
|
|
14
|
+
function isTableResource(resource) {
|
|
15
|
+
return (!!resource.codec &&
|
|
16
|
+
!resource.codec.isAnonymous &&
|
|
17
|
+
isRecord(resource.codec.attributes) &&
|
|
18
|
+
!resource.parameters &&
|
|
19
|
+
!resource.isVirtual &&
|
|
20
|
+
!resource.isUnique);
|
|
21
|
+
}
|
|
22
|
+
function getSchemaName(resource) {
|
|
23
|
+
const schemaName = resource.codec?.extensions?.pg?.schemaName;
|
|
24
|
+
if (typeof schemaName !== 'string' || schemaName.length === 0)
|
|
25
|
+
return null;
|
|
26
|
+
return schemaName;
|
|
27
|
+
}
|
|
28
|
+
function getUniques(resource) {
|
|
29
|
+
return Array.isArray(resource.uniques) ? resource.uniques : [];
|
|
30
|
+
}
|
|
31
|
+
function getRelations(resource) {
|
|
32
|
+
return resource.relations || resource.getRelations?.() || {};
|
|
33
|
+
}
|
|
34
|
+
function getRelation(resource, relationName) {
|
|
35
|
+
if (!relationName)
|
|
36
|
+
return null;
|
|
37
|
+
if (typeof resource.getRelation === 'function') {
|
|
38
|
+
return resource.getRelation(relationName) || null;
|
|
39
|
+
}
|
|
40
|
+
const relations = getRelations(resource);
|
|
41
|
+
return relations[relationName] || null;
|
|
42
|
+
}
|
|
43
|
+
function sameAttributes(uniqueAttributes, relationAttributes) {
|
|
44
|
+
if (!uniqueAttributes || !relationAttributes)
|
|
45
|
+
return false;
|
|
46
|
+
return (uniqueAttributes.length === relationAttributes.length &&
|
|
47
|
+
uniqueAttributes.every((attrName) => relationAttributes.includes(attrName)));
|
|
48
|
+
}
|
|
49
|
+
function getConfiguredSchemas(build) {
|
|
50
|
+
const pgSchemas = build.options?.pgSchemas;
|
|
51
|
+
if (!Array.isArray(pgSchemas))
|
|
52
|
+
return [];
|
|
53
|
+
return pgSchemas.filter((schemaName) => typeof schemaName === 'string');
|
|
54
|
+
}
|
|
55
|
+
function getResourceCodec(resource) {
|
|
56
|
+
const codec = resource.codec;
|
|
57
|
+
if (!codec?.attributes)
|
|
58
|
+
return null;
|
|
59
|
+
return codec;
|
|
60
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { FieldMeta, GqlTypeResolverBuild, PgAttribute } from './types';
|
|
2
|
+
export declare function pgTypeToGqlType(pgTypeName: string): string;
|
|
3
|
+
export declare function buildFieldMeta(name: string, attr: PgAttribute | null | undefined, build?: GqlTypeResolverBuild): FieldMeta;
|