@pothos/plugin-prisma 0.16.3 → 0.18.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 +33 -0
- package/esm/cursors.d.ts +9 -7
- package/esm/cursors.d.ts.map +1 -1
- package/esm/cursors.js +34 -13
- package/esm/cursors.js.map +1 -1
- package/esm/field-builder.js +10 -12
- package/esm/field-builder.js.map +1 -1
- package/esm/prisma-field-builder.d.ts.map +1 -1
- package/esm/prisma-field-builder.js +5 -3
- package/esm/prisma-field-builder.js.map +1 -1
- package/esm/refs.d.ts +5 -0
- package/esm/refs.d.ts.map +1 -1
- package/esm/refs.js +28 -8
- package/esm/refs.js.map +1 -1
- package/esm/schema-builder.js +1 -1
- package/esm/schema-builder.js.map +1 -1
- package/esm/types.d.ts.map +1 -1
- package/esm/util/map-includes.d.ts.map +1 -1
- package/esm/util/map-includes.js +2 -2
- package/esm/util/map-includes.js.map +1 -1
- package/lib/cursors.d.ts +9 -7
- package/lib/cursors.d.ts.map +1 -1
- package/lib/cursors.js +39 -14
- package/lib/cursors.js.map +1 -1
- package/lib/field-builder.js +9 -11
- package/lib/field-builder.js.map +1 -1
- package/lib/prisma-field-builder.d.ts.map +1 -1
- package/lib/prisma-field-builder.js +4 -2
- package/lib/prisma-field-builder.js.map +1 -1
- package/lib/refs.d.ts +5 -0
- package/lib/refs.d.ts.map +1 -1
- package/lib/refs.js +32 -9
- package/lib/refs.js.map +1 -1
- package/lib/schema-builder.js +1 -1
- package/lib/schema-builder.js.map +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/util/map-includes.d.ts.map +1 -1
- package/lib/util/map-includes.js +2 -2
- package/lib/util/map-includes.js.map +1 -1
- package/package.json +10 -10
- package/src/cursors.ts +44 -19
- package/src/field-builder.ts +10 -10
- package/src/prisma-field-builder.ts +13 -3
- package/src/refs.ts +45 -8
- package/src/schema-builder.ts +1 -1
- package/src/types.ts +0 -2
- package/src/util/map-includes.ts +2 -3
- package/.turbo/turbo-build.log +0 -17
- package/.turbo/turbo-test.log +0 -18
- package/.turbo/turbo-type.log +0 -5
- package/babel.config.js +0 -3
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map-includes.js","sourceRoot":"","sources":["../../src/util/map-includes.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,sCAAsC;AACtC,gCAAgC;AAChC,qCAQiB;AACjB,qDAA6D;AAC7D,8CAAkD;AAQlD,wBAAuD;AAE1C,QAAA,aAAa,GAAG,OAAO,CAAC;AAErC,SAAS,WAAW,CAClB,GAAW,EACX,IAAwB,EACxB,MAAyC,EACzC,SAAoB,EACpB,QAAoB,EACpB,MAAqB,EACrB,QAAwB,EACxB,WAA6B;;IAE7B,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QACzC,OAAO;KACR;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAE3C,IAAI,CAAC,KAAK,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;KAC1D;IAED,MAAM,SAAS,GAAG,MAAA,KAAK,CAAC,UAAU,0CAAE,yBAA+C,CAAC;IACpF,MAAM,eAAe,GAAG,MAAA,KAAK,CAAC,UAAU,0CAAE,kCAE7B,CAAC;IACd,MAAM,YAAY,GAAG,MAAA,KAAK,CAAC,UAAU,0CAAE,oBAA0C,CAAC;IAElF,IAAI,SAAS,EAAE;QACb,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;KAClC;IAED,IAAI,eAAe,EAAE;QACnB,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,GAAG,IAAI,CAAC;KACvC;IAED,IAAI,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,SAAS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EAAE,QAAQ,CAAC,CAAC;SAC7C;QAED,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;KAC9B;IAED,OAAO,EAAE,CAAC;AACZ,CAAC;AApCD,sCAoCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pothos/plugin-prisma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "A Pothos plugin for more efficient integration with prisma",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@prisma/generator-helper": "^3.9.
|
|
39
|
+
"@prisma/generator-helper": "^3.9.2"
|
|
40
40
|
},
|
|
41
41
|
"prisma": {
|
|
42
42
|
"seed": "pnpm ts-node prisma/seed.ts"
|
|
@@ -47,19 +47,19 @@
|
|
|
47
47
|
"typescript": ">4.5.2"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@pothos/core": "3.
|
|
51
|
-
"@pothos/plugin-errors": "3.
|
|
52
|
-
"@pothos/plugin-relay": "3.
|
|
53
|
-
"@pothos/plugin-scope-auth": "3.
|
|
54
|
-
"@pothos/test-utils": "1.0.
|
|
55
|
-
"@prisma/client": "^3.9.
|
|
50
|
+
"@pothos/core": "3.3.2",
|
|
51
|
+
"@pothos/plugin-errors": "3.1.1",
|
|
52
|
+
"@pothos/plugin-relay": "3.5.1",
|
|
53
|
+
"@pothos/plugin-scope-auth": "3.4.1",
|
|
54
|
+
"@pothos/test-utils": "1.0.2",
|
|
55
|
+
"@prisma/client": "^3.9.2",
|
|
56
56
|
"graphql": "16.3.0",
|
|
57
57
|
"graphql-tag": "^2.12.6",
|
|
58
|
-
"prisma": "^3.9.
|
|
58
|
+
"prisma": "^3.9.2"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"generate": "prisma generate",
|
|
62
|
-
"ts-node": "ts-node --compiler-options \"{\\\"module\\\":\\\"commonjs\\\"}\"",
|
|
62
|
+
"ts-node": "ts-node --transpile-only --compiler-options \"{\\\"module\\\":\\\"commonjs\\\"}\"",
|
|
63
63
|
"type": "tsc --noEmit && tsc --project tests/tsconfig.json",
|
|
64
64
|
"build": "pnpm build:cjs && pnpm build:esm",
|
|
65
65
|
"build:cjs": "tsc --module commonjs --outDir lib",
|
package/src/cursors.ts
CHANGED
|
@@ -4,22 +4,34 @@ import { MaybePromise } from '@pothos/core';
|
|
|
4
4
|
const DEFAULT_MAX_SIZE = 100;
|
|
5
5
|
const DEFAULT_SIZE = 20;
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
export function formatCursorChunk(value: unknown) {
|
|
8
8
|
if (value instanceof Date) {
|
|
9
|
-
return
|
|
9
|
+
return `D:${String(Number(value))}`;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
switch (typeof value) {
|
|
13
13
|
case 'number':
|
|
14
|
-
return
|
|
14
|
+
return `N:${value}`;
|
|
15
15
|
case 'string':
|
|
16
|
-
return
|
|
16
|
+
return `S:${value}`;
|
|
17
17
|
default:
|
|
18
18
|
throw new TypeError(`Unsupported cursor type ${typeof value}`);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
function
|
|
22
|
+
export function formatCursor(fields: string | string[]) {
|
|
23
|
+
return (value: Record<string, unknown>) => {
|
|
24
|
+
if (typeof fields === 'string') {
|
|
25
|
+
return Buffer.from(`GPC:${formatCursorChunk(value[fields])}`).toString('base64');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return Buffer.from(`GPC:J:${JSON.stringify(fields.map((name) => value[name]))}`).toString(
|
|
29
|
+
'base64',
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function parseRawCursor(cursor: unknown) {
|
|
23
35
|
if (typeof cursor !== 'string') {
|
|
24
36
|
throw new TypeError('Cursor must be a string');
|
|
25
37
|
}
|
|
@@ -35,6 +47,8 @@ function parseCursor(cursor: unknown) {
|
|
|
35
47
|
return Number.parseInt(value, 10);
|
|
36
48
|
case 'D':
|
|
37
49
|
return new Date(Number.parseInt(value, 10));
|
|
50
|
+
case 'J':
|
|
51
|
+
return JSON.parse(value) as unknown;
|
|
38
52
|
default:
|
|
39
53
|
throw new TypeError(`Invalid cursor type ${type}`);
|
|
40
54
|
}
|
|
@@ -43,11 +57,29 @@ function parseCursor(cursor: unknown) {
|
|
|
43
57
|
}
|
|
44
58
|
}
|
|
45
59
|
|
|
60
|
+
export function parseCompositeCursor(fields: string[]) {
|
|
61
|
+
return (cursor: string) => {
|
|
62
|
+
const parsed = parseRawCursor(cursor) as unknown[];
|
|
63
|
+
|
|
64
|
+
if (!Array.isArray(parsed)) {
|
|
65
|
+
throw new TypeError(`Expected compound cursor to contain an array, but got ${parsed}`);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const record: Record<string, unknown> = {};
|
|
69
|
+
|
|
70
|
+
fields.forEach((field, i) => {
|
|
71
|
+
record[field] = parsed[i];
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
return record;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
46
78
|
interface PrismaCursorConnectionQueryOptions {
|
|
47
79
|
args: PothosSchemaTypes.DefaultConnectionArguments;
|
|
48
80
|
defaultSize?: number;
|
|
49
81
|
maxSize?: number;
|
|
50
|
-
|
|
82
|
+
parseCursor: (cursor: string) => Record<string, unknown>;
|
|
51
83
|
}
|
|
52
84
|
|
|
53
85
|
interface ResolvePrismaCursorConnectionOptions extends PrismaCursorConnectionQueryOptions {
|
|
@@ -59,7 +91,7 @@ export function prismaCursorConnectionQuery({
|
|
|
59
91
|
args: { before, after, first, last },
|
|
60
92
|
maxSize = DEFAULT_MAX_SIZE,
|
|
61
93
|
defaultSize = DEFAULT_SIZE,
|
|
62
|
-
|
|
94
|
+
parseCursor,
|
|
63
95
|
}: PrismaCursorConnectionQueryOptions) {
|
|
64
96
|
if (first != null && first < 0) {
|
|
65
97
|
throw new TypeError('Argument "first" must be a non-negative integer');
|
|
@@ -96,9 +128,7 @@ export function prismaCursorConnectionQuery({
|
|
|
96
128
|
return cursor == null
|
|
97
129
|
? { take, skip: 0 }
|
|
98
130
|
: {
|
|
99
|
-
cursor:
|
|
100
|
-
[column]: parseCursor(cursor),
|
|
101
|
-
},
|
|
131
|
+
cursor: parseCursor(cursor),
|
|
102
132
|
take,
|
|
103
133
|
skip: 1,
|
|
104
134
|
};
|
|
@@ -108,7 +138,7 @@ export function wrapConnectionResult<T extends {}>(
|
|
|
108
138
|
results: T[],
|
|
109
139
|
args: PothosSchemaTypes.DefaultConnectionArguments,
|
|
110
140
|
take: number,
|
|
111
|
-
|
|
141
|
+
cursor: (node: T) => string,
|
|
112
142
|
totalCount?: number,
|
|
113
143
|
) {
|
|
114
144
|
const gotFullResults = results.length === Math.abs(take);
|
|
@@ -122,7 +152,7 @@ export function wrapConnectionResult<T extends {}>(
|
|
|
122
152
|
value == null
|
|
123
153
|
? null
|
|
124
154
|
: {
|
|
125
|
-
cursor:
|
|
155
|
+
cursor: cursor(value),
|
|
126
156
|
node: value,
|
|
127
157
|
},
|
|
128
158
|
);
|
|
@@ -141,6 +171,7 @@ export function wrapConnectionResult<T extends {}>(
|
|
|
141
171
|
|
|
142
172
|
export async function resolvePrismaCursorConnection<T extends {}>(
|
|
143
173
|
options: ResolvePrismaCursorConnectionOptions,
|
|
174
|
+
cursor: (node: T) => string,
|
|
144
175
|
resolve: (query: { include?: {}; cursor?: {}; take: number; skip: number }) => MaybePromise<T[]>,
|
|
145
176
|
) {
|
|
146
177
|
const query = prismaCursorConnectionQuery(options);
|
|
@@ -149,11 +180,5 @@ export async function resolvePrismaCursorConnection<T extends {}>(
|
|
|
149
180
|
...query,
|
|
150
181
|
});
|
|
151
182
|
|
|
152
|
-
return wrapConnectionResult(
|
|
153
|
-
results,
|
|
154
|
-
options.args,
|
|
155
|
-
query.take,
|
|
156
|
-
options.column,
|
|
157
|
-
options.totalCount,
|
|
158
|
-
);
|
|
183
|
+
return wrapConnectionResult(results, options.args, query.take, cursor, options.totalCount);
|
|
159
184
|
}
|
package/src/field-builder.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
SchemaTypes,
|
|
9
9
|
} from '@pothos/core';
|
|
10
10
|
import { resolvePrismaCursorConnection } from './cursors';
|
|
11
|
-
import { getRefFromModel } from './refs';
|
|
11
|
+
import { getCursorFormatter, getCursorParser, getRefFromModel } from './refs';
|
|
12
12
|
import { PrismaConnectionFieldOptions, PrismaModelTypes } from './types';
|
|
13
13
|
import { queryFromInfo } from './util';
|
|
14
14
|
|
|
@@ -69,7 +69,12 @@ fieldBuilderProto.prismaConnection = function prismaConnection<
|
|
|
69
69
|
edgeOptions: {},
|
|
70
70
|
) {
|
|
71
71
|
const ref = typeof type === 'string' ? getRefFromModel(type, this.builder) : type;
|
|
72
|
-
|
|
72
|
+
const typeName = this.builder.configStore.getTypeConfig(ref).name;
|
|
73
|
+
|
|
74
|
+
const model = this.builder.configStore.getTypeConfig(ref).extensions?.pothosPrismaModel as string;
|
|
75
|
+
|
|
76
|
+
const formatCursor = getCursorFormatter(model, this.builder, cursor);
|
|
77
|
+
const parseCursor = getCursorParser(model, this.builder, cursor);
|
|
73
78
|
|
|
74
79
|
const fieldRef = (
|
|
75
80
|
this as typeof fieldBuilderProto & { connection: (...args: unknown[]) => FieldRef<unknown> }
|
|
@@ -86,11 +91,12 @@ fieldBuilderProto.prismaConnection = function prismaConnection<
|
|
|
86
91
|
resolvePrismaCursorConnection(
|
|
87
92
|
{
|
|
88
93
|
query: queryFromInfo(ctx, info),
|
|
89
|
-
|
|
94
|
+
parseCursor,
|
|
90
95
|
maxSize,
|
|
91
96
|
defaultSize,
|
|
92
97
|
args,
|
|
93
98
|
},
|
|
99
|
+
formatCursor,
|
|
94
100
|
(query) => resolve(query as never, parent, args as never, ctx, info),
|
|
95
101
|
),
|
|
96
102
|
},
|
|
@@ -99,13 +105,7 @@ fieldBuilderProto.prismaConnection = function prismaConnection<
|
|
|
99
105
|
extensions: {
|
|
100
106
|
...(connectionOptions as Record<string, {}> | undefined)?.extensions,
|
|
101
107
|
pothosPrismaIndirectInclude: {
|
|
102
|
-
getType: () =>
|
|
103
|
-
if (!typeName) {
|
|
104
|
-
typeName = this.builder.configStore.getTypeConfig(ref).name;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return typeName;
|
|
108
|
-
},
|
|
108
|
+
getType: () => typeName,
|
|
109
109
|
path: [{ name: 'edges' }, { name: 'node' }],
|
|
110
110
|
},
|
|
111
111
|
},
|
|
@@ -14,7 +14,14 @@ import { prismaCursorConnectionQuery, wrapConnectionResult } from './cursors';
|
|
|
14
14
|
import { getLoaderMapping, setLoaderMappings } from './loader-map';
|
|
15
15
|
import { ModelLoader } from './model-loader';
|
|
16
16
|
import { PrismaObjectRef } from './object-ref';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
getCursorFormatter,
|
|
19
|
+
getCursorParser,
|
|
20
|
+
getDelegateFromModel,
|
|
21
|
+
getFindUniqueForRef,
|
|
22
|
+
getRefFromModel,
|
|
23
|
+
getRelation,
|
|
24
|
+
} from './refs';
|
|
18
25
|
import {
|
|
19
26
|
PrismaDelegate,
|
|
20
27
|
PrismaModelTypes,
|
|
@@ -96,10 +103,13 @@ export class PrismaObjectFieldBuilder<
|
|
|
96
103
|
const loaderCache = ModelLoader.forModel(this.model, this.builder);
|
|
97
104
|
let typeName: string | undefined;
|
|
98
105
|
|
|
106
|
+
const formatCursor = getCursorFormatter(relationField.type, this.builder, cursor);
|
|
107
|
+
const parseCursor = getCursorParser(relationField.type, this.builder, cursor);
|
|
108
|
+
|
|
99
109
|
const getQuery = (args: PothosSchemaTypes.DefaultConnectionArguments, ctx: {}) => ({
|
|
100
110
|
...((typeof query === 'function' ? query(args, ctx) : query) as {}),
|
|
101
111
|
...prismaCursorConnectionQuery({
|
|
102
|
-
|
|
112
|
+
parseCursor,
|
|
103
113
|
maxSize,
|
|
104
114
|
defaultSize,
|
|
105
115
|
args,
|
|
@@ -160,7 +170,7 @@ export class PrismaObjectFieldBuilder<
|
|
|
160
170
|
await getResult(),
|
|
161
171
|
args,
|
|
162
172
|
connectionQuery.take,
|
|
163
|
-
|
|
173
|
+
formatCursor,
|
|
164
174
|
(parent as { _count?: Record<string, number> })._count?.[name],
|
|
165
175
|
);
|
|
166
176
|
},
|
package/src/refs.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ObjectRef, SchemaTypes } from '@pothos/core';
|
|
2
2
|
import { Prisma } from '../tests/client';
|
|
3
|
+
import { formatCursor, parseCompositeCursor, parseRawCursor } from './cursors';
|
|
3
4
|
import { PrismaObjectRef } from './object-ref';
|
|
4
5
|
import { PrismaDelegate } from './types';
|
|
5
6
|
import { PrismaModelTypes } from '.';
|
|
@@ -65,6 +66,25 @@ export function getRelation<Types extends SchemaTypes>(
|
|
|
65
66
|
name: string,
|
|
66
67
|
builder: PothosSchemaTypes.SchemaBuilder<Types>,
|
|
67
68
|
relation: string,
|
|
69
|
+
) {
|
|
70
|
+
const modelData = getModel(name, builder);
|
|
71
|
+
|
|
72
|
+
const fieldData = modelData.fields.find((field) => field.name === relation);
|
|
73
|
+
|
|
74
|
+
if (!fieldData) {
|
|
75
|
+
throw new Error(`Field '${relation}' not found in model '${name}'`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (fieldData.kind !== 'object') {
|
|
79
|
+
throw new Error(`Field ${relation} of model '${name}' is not a relation (${fieldData.kind})`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return fieldData;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function getModel<Types extends SchemaTypes>(
|
|
86
|
+
name: string,
|
|
87
|
+
builder: PothosSchemaTypes.SchemaBuilder<Types>,
|
|
68
88
|
) {
|
|
69
89
|
const { client } = builder.options.prisma;
|
|
70
90
|
// eslint-disable-next-line no-underscore-dangle
|
|
@@ -76,17 +96,34 @@ export function getRelation<Types extends SchemaTypes>(
|
|
|
76
96
|
throw new Error(`Model '${name}' not found in DMMF`);
|
|
77
97
|
}
|
|
78
98
|
|
|
79
|
-
|
|
99
|
+
return modelData;
|
|
100
|
+
}
|
|
80
101
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
102
|
+
export function getCursorFormatter<Types extends SchemaTypes>(
|
|
103
|
+
name: string,
|
|
104
|
+
builder: PothosSchemaTypes.SchemaBuilder<Types>,
|
|
105
|
+
cursor: string,
|
|
106
|
+
) {
|
|
107
|
+
const modelData = getModel(name, builder);
|
|
108
|
+
const primaryKey = modelData.primaryKey?.name ?? modelData.primaryKey?.fields.join('_');
|
|
84
109
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
110
|
+
return formatCursor(cursor === primaryKey ? modelData.primaryKey!.fields : cursor);
|
|
111
|
+
}
|
|
88
112
|
|
|
89
|
-
|
|
113
|
+
export function getCursorParser<Types extends SchemaTypes>(
|
|
114
|
+
name: string,
|
|
115
|
+
builder: PothosSchemaTypes.SchemaBuilder<Types>,
|
|
116
|
+
cursor: string,
|
|
117
|
+
) {
|
|
118
|
+
const modelData = getModel(name, builder);
|
|
119
|
+
const primaryKey = modelData.primaryKey?.name ?? modelData.primaryKey?.fields.join('_');
|
|
120
|
+
|
|
121
|
+
const parser =
|
|
122
|
+
cursor === primaryKey ? parseCompositeCursor(modelData.primaryKey!.fields) : parseRawCursor;
|
|
123
|
+
|
|
124
|
+
return (rawCursor: string) => ({
|
|
125
|
+
[cursor]: parser(rawCursor),
|
|
126
|
+
});
|
|
90
127
|
}
|
|
91
128
|
|
|
92
129
|
export function getRelatedDelegate<Types extends SchemaTypes>(
|
package/src/schema-builder.ts
CHANGED
|
@@ -37,6 +37,7 @@ schemaBuilderProto.prismaObject = function prismaObject(type, { fields, findUniq
|
|
|
37
37
|
extensions: {
|
|
38
38
|
...options.extensions,
|
|
39
39
|
pothosPrismaInclude: options.include,
|
|
40
|
+
pothosPrismaModel: type,
|
|
40
41
|
},
|
|
41
42
|
name,
|
|
42
43
|
fields: fields ? () => fields(new PrismaObjectFieldBuilder(name, this, type)) : undefined,
|
|
@@ -70,7 +71,6 @@ schemaBuilderProto.prismaNode = function prismaNode(
|
|
|
70
71
|
...options,
|
|
71
72
|
variant,
|
|
72
73
|
interfaces: [interfaceRef, ...(options.interfaces ?? [])],
|
|
73
|
-
isTypeOf: (val: unknown) => nodeRef.hasBrand(val),
|
|
74
74
|
findUnique: (parent: unknown, context: {}) =>
|
|
75
75
|
findUnique(options.id.resolve(parent as never, context) as string, context),
|
|
76
76
|
loadWithoutCache: async (
|
package/src/types.ts
CHANGED
|
@@ -359,7 +359,6 @@ export type PrismaConnectionFieldOptions<
|
|
|
359
359
|
Args extends InputFieldMap,
|
|
360
360
|
ResolveReturnShape,
|
|
361
361
|
Kind extends FieldKind,
|
|
362
|
-
// eslint-disable-next-line @typescript-eslint/sort-type-union-intersection-members
|
|
363
362
|
> = Omit<
|
|
364
363
|
PothosSchemaTypes.ConnectionFieldOptions<
|
|
365
364
|
Types,
|
|
@@ -411,7 +410,6 @@ export type RelatedConnectionOptions<
|
|
|
411
410
|
Nullable extends boolean,
|
|
412
411
|
Args extends InputFieldMap,
|
|
413
412
|
NeedsResolve extends boolean,
|
|
414
|
-
// eslint-disable-next-line @typescript-eslint/sort-type-union-intersection-members
|
|
415
413
|
> = Omit<
|
|
416
414
|
PothosSchemaTypes.ObjectFieldOptions<
|
|
417
415
|
Types,
|
package/src/util/map-includes.ts
CHANGED
|
@@ -291,7 +291,8 @@ export function includesFromSelectionSet(
|
|
|
291
291
|
|
|
292
292
|
export function queryFromInfo(ctx: object, info: GraphQLResolveInfo, typeName?: string): {} {
|
|
293
293
|
const { fieldNodes } = info;
|
|
294
|
-
const
|
|
294
|
+
const type = typeName ? info.schema.getTypeMap()[typeName] : getNamedType(info.returnType);
|
|
295
|
+
const includeType = resolveIndirectType(type, info);
|
|
295
296
|
|
|
296
297
|
const includes: IncludeMap = {
|
|
297
298
|
...(includeType.extensions?.pothosPrismaInclude as IncludeMap),
|
|
@@ -308,8 +309,6 @@ export function queryFromInfo(ctx: object, info: GraphQLResolveInfo, typeName?:
|
|
|
308
309
|
continue;
|
|
309
310
|
}
|
|
310
311
|
|
|
311
|
-
const type = typeName ? info.schema.getTypeMap()[typeName] : getNamedType(info.returnType);
|
|
312
|
-
|
|
313
312
|
includesFromSelectionSet(ctx, type, info, includes, counts, mappings, node.selectionSet);
|
|
314
313
|
}
|
|
315
314
|
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
@pothos/plugin-prisma:build: cache hit, replaying output b83a6107559e2033
|
|
2
|
-
@pothos/plugin-prisma:build:
|
|
3
|
-
@pothos/plugin-prisma:build: > @pothos/plugin-prisma@0.16.3 build /home/runner/work/pothos/pothos/packages/plugin-prisma
|
|
4
|
-
@pothos/plugin-prisma:build: > pnpm build:cjs && pnpm build:esm
|
|
5
|
-
@pothos/plugin-prisma:build:
|
|
6
|
-
@pothos/plugin-prisma:build:
|
|
7
|
-
@pothos/plugin-prisma:build: > @pothos/plugin-prisma@0.16.3 build:cjs /home/runner/work/pothos/pothos/packages/plugin-prisma
|
|
8
|
-
@pothos/plugin-prisma:build: > tsc --module commonjs --outDir lib
|
|
9
|
-
@pothos/plugin-prisma:build:
|
|
10
|
-
@pothos/plugin-prisma:build:
|
|
11
|
-
@pothos/plugin-prisma:build: > @pothos/plugin-prisma@0.16.3 build:esm /home/runner/work/pothos/pothos/packages/plugin-prisma
|
|
12
|
-
@pothos/plugin-prisma:build: > tsc --module es2020 --outDir esm && pnpm esm:extensions
|
|
13
|
-
@pothos/plugin-prisma:build:
|
|
14
|
-
@pothos/plugin-prisma:build:
|
|
15
|
-
@pothos/plugin-prisma:build: > @pothos/plugin-prisma@0.16.3 esm:extensions /home/runner/work/pothos/pothos/packages/plugin-prisma
|
|
16
|
-
@pothos/plugin-prisma:build: > ts-node --compiler-options "{\"module\":\"commonjs\"}" ../../.config/esm-transformer.ts
|
|
17
|
-
@pothos/plugin-prisma:build:
|
package/.turbo/turbo-test.log
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
@pothos/plugin-prisma:test: cache hit, replaying output a408f95bdf6da44c
|
|
2
|
-
@pothos/plugin-prisma:test:
|
|
3
|
-
@pothos/plugin-prisma:test: > @pothos/plugin-prisma@0.16.3 test /home/runner/work/pothos/pothos/packages/plugin-prisma
|
|
4
|
-
@pothos/plugin-prisma:test: > pnpm jest --runInBand
|
|
5
|
-
@pothos/plugin-prisma:test:
|
|
6
|
-
@pothos/plugin-prisma:test: PASS tests/connections.test.ts (30.484 s)
|
|
7
|
-
@pothos/plugin-prisma:test: PASS tests/index.test.ts
|
|
8
|
-
@pothos/plugin-prisma:test: PASS tests/counts.test.ts
|
|
9
|
-
@pothos/plugin-prisma:test: PASS tests/nodes.test.ts
|
|
10
|
-
@pothos/plugin-prisma:test: PASS tests/relation-query.test.ts
|
|
11
|
-
@pothos/plugin-prisma:test: PASS tests/variants.test.ts
|
|
12
|
-
@pothos/plugin-prisma:test: PASS tests/type-include.test.ts
|
|
13
|
-
@pothos/plugin-prisma:test:
|
|
14
|
-
@pothos/plugin-prisma:test: Test Suites: 7 passed, 7 total
|
|
15
|
-
@pothos/plugin-prisma:test: Tests: 35 passed, 35 total
|
|
16
|
-
@pothos/plugin-prisma:test: Snapshots: 69 passed, 69 total
|
|
17
|
-
@pothos/plugin-prisma:test: Time: 51.444 s
|
|
18
|
-
@pothos/plugin-prisma:test: Ran all test suites.
|
package/.turbo/turbo-type.log
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
@pothos/plugin-prisma:type: cache hit, replaying output 1651826caca1af0e
|
|
2
|
-
@pothos/plugin-prisma:type:
|
|
3
|
-
@pothos/plugin-prisma:type: > @pothos/plugin-prisma@0.16.3 type /home/runner/work/pothos/pothos/packages/plugin-prisma
|
|
4
|
-
@pothos/plugin-prisma:type: > tsc --noEmit && tsc --project tests/tsconfig.json
|
|
5
|
-
@pothos/plugin-prisma:type:
|
package/babel.config.js
DELETED