@pothos/plugin-drizzle 0.13.0 → 0.14.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/CHANGELOG.md +6 -0
- package/README.md +2 -2
- package/dts/drizzle-field-builder.d.ts.map +1 -1
- package/dts/global-types.d.ts.map +1 -1
- package/dts/utils/config.d.ts.map +1 -1
- package/dts/utils/drizzle-graphql.d.ts +1 -0
- package/dts/utils/drizzle-graphql.d.ts.map +1 -1
- package/dts/utils/usage.d.ts +1 -1
- package/esm/drizzle-field-builder.d.ts.map +1 -1
- package/esm/drizzle-field-builder.js +2 -1
- package/esm/drizzle-field-builder.js.map +1 -1
- package/esm/global-types.d.ts.map +1 -1
- package/esm/model-loader.js +2 -2
- package/esm/model-loader.js.map +1 -1
- package/esm/utils/config.d.ts.map +1 -1
- package/esm/utils/config.js +8 -12
- package/esm/utils/config.js.map +1 -1
- package/esm/utils/cursors.js +2 -2
- package/esm/utils/cursors.js.map +1 -1
- package/esm/utils/drizzle-graphql.d.ts +1 -0
- package/esm/utils/drizzle-graphql.d.ts.map +1 -1
- package/esm/utils/drizzle-graphql.js +1 -1
- package/esm/utils/drizzle-graphql.js.map +1 -1
- package/esm/utils/map-query.js +1 -2
- package/esm/utils/map-query.js.map +1 -1
- package/esm/utils/usage.d.ts +1 -1
- package/lib/drizzle-field-builder.js +2 -1
- package/lib/drizzle-field-builder.js.map +1 -1
- package/lib/model-loader.js +1 -1
- package/lib/model-loader.js.map +1 -1
- package/lib/utils/config.js +7 -11
- package/lib/utils/config.js.map +1 -1
- package/lib/utils/cursors.js +1 -1
- package/lib/utils/cursors.js.map +1 -1
- package/lib/utils/drizzle-graphql.js +233 -230
- package/lib/utils/drizzle-graphql.js.map +1 -1
- package/lib/utils/map-query.js +1 -2
- package/lib/utils/map-query.js.map +1 -1
- package/package.json +7 -7
- package/src/drizzle-field-builder.ts +2 -1
- package/src/global-types.ts +0 -4
- package/src/model-loader.ts +2 -2
- package/src/utils/config.ts +8 -12
- package/src/utils/cursors.ts +2 -2
- package/src/utils/drizzle-graphql.ts +1 -0
- package/src/utils/map-query.ts +1 -1
- package/src/utils/usage.ts +1 -1
package/src/utils/config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContextCache, type SchemaTypes } from '@pothos/core';
|
|
2
|
-
import { type AnyRelations, type Column,
|
|
2
|
+
import { type AnyRelations, type Column, getColumns, isTable, type Table } from 'drizzle-orm';
|
|
3
3
|
import type { DrizzleClient } from '../types';
|
|
4
4
|
|
|
5
5
|
export interface PothosDrizzleSchemaConfig {
|
|
@@ -17,14 +17,12 @@ const configCache = createContextCache(
|
|
|
17
17
|
relations = (builder.options.drizzle.client as DrizzleClient)._.relations;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
const columnNameMappings
|
|
20
|
+
const columnNameMappings = new Map<Column, string>();
|
|
21
21
|
|
|
22
22
|
Object.values(relations).forEach(({ table }) => {
|
|
23
23
|
if (isTable(table)) {
|
|
24
|
-
Object.entries(
|
|
25
|
-
|
|
26
|
-
columnNameMappings[col.uniqueName] = tsName;
|
|
27
|
-
}
|
|
24
|
+
Object.entries(getColumns(table)).forEach(([tsName, col]) => {
|
|
25
|
+
columnNameMappings.set(col, tsName);
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
});
|
|
@@ -32,15 +30,13 @@ const configCache = createContextCache(
|
|
|
32
30
|
return {
|
|
33
31
|
skipDeferredFragments: builder.options.drizzle.skipDeferredFragments ?? true,
|
|
34
32
|
columnToTsName: (column) => {
|
|
35
|
-
|
|
36
|
-
throw new Error(`Column ${String(column.name)} has no uniqueName`);
|
|
37
|
-
}
|
|
33
|
+
const tsName = columnNameMappings.get(column);
|
|
38
34
|
|
|
39
|
-
if (!
|
|
40
|
-
throw new Error(`Typescript name not found for ${column.
|
|
35
|
+
if (!tsName) {
|
|
36
|
+
throw new Error(`Typescript name not found for column ${String(column.name)}`);
|
|
41
37
|
}
|
|
42
38
|
|
|
43
|
-
return
|
|
39
|
+
return tsName;
|
|
44
40
|
},
|
|
45
41
|
getPrimaryKey: (tableName) => {
|
|
46
42
|
const tableConfig = builder.options.drizzle.getTableConfig(
|
package/src/utils/cursors.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
type Column,
|
|
10
10
|
type DBQueryConfig,
|
|
11
|
-
|
|
11
|
+
getColumns,
|
|
12
12
|
type SQL,
|
|
13
13
|
type Table,
|
|
14
14
|
type TableRelationalConfig,
|
|
@@ -322,7 +322,7 @@ function parseOrderBy(
|
|
|
322
322
|
normalized.push({ direction: 'asc', column: field });
|
|
323
323
|
}
|
|
324
324
|
} else {
|
|
325
|
-
const tableColumns =
|
|
325
|
+
const tableColumns = getColumns(table.table as Table);
|
|
326
326
|
Object.entries(
|
|
327
327
|
orderBy as {
|
|
328
328
|
[k: string]: 'asc' | 'desc' | undefined;
|
package/src/utils/map-query.ts
CHANGED
|
@@ -567,7 +567,7 @@ export function getIndirectType(type: GraphQLNamedType, info: GraphQLResolveInfo
|
|
|
567
567
|
|
|
568
568
|
while (targetType.extensions?.pothosIndirectInclude) {
|
|
569
569
|
targetType = info.schema.getType(
|
|
570
|
-
(targetType.extensions
|
|
570
|
+
(targetType.extensions.pothosIndirectInclude as IndirectInclude).getType(),
|
|
571
571
|
)!;
|
|
572
572
|
}
|
|
573
573
|
|
package/src/utils/usage.ts
CHANGED