@lssm/lib.graphql-prisma 0.0.0-canary-20251221193616 → 0.0.0-canary-20251223010757
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/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/dist/schema/dist/index.js +0 -4661
- package/dist/schema/dist/index.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { E5 } from "./schema/dist/index.js";
|
|
2
1
|
import SchemaBuilder from "@pothos/core";
|
|
3
2
|
import PrismaPlugin from "@pothos/plugin-prisma";
|
|
4
3
|
import ComplexityPlugin from "@pothos/plugin-complexity";
|
|
@@ -6,6 +5,7 @@ import DataloaderPlugin from "@pothos/plugin-dataloader";
|
|
|
6
5
|
import RelayPlugin from "@pothos/plugin-relay";
|
|
7
6
|
import TracingPlugin, { isRootField, wrapResolver } from "@pothos/plugin-tracing";
|
|
8
7
|
import { GeoJSONResolver } from "graphql-scalars";
|
|
8
|
+
import { ScalarTypeEnum } from "@lssm/lib.schema";
|
|
9
9
|
|
|
10
10
|
//#region src/index.ts
|
|
11
11
|
function createPrismaSchemaBuilder(options) {
|
|
@@ -39,7 +39,7 @@ function createPrismaSchemaBuilder(options) {
|
|
|
39
39
|
}
|
|
40
40
|
});
|
|
41
41
|
if (debugBuilder) console.log("[graphql-prisma] initializing schema builder");
|
|
42
|
-
Object.entries(
|
|
42
|
+
Object.entries(ScalarTypeEnum).forEach(([name, type]) => {
|
|
43
43
|
if (["ID", "Boolean"].includes(name)) return;
|
|
44
44
|
if (typeof type !== "function") throw new Error(`ScalarTypeEnum entry "${name}" must be a function but received ${typeof type}`);
|
|
45
45
|
if (debugBuilder) console.log(`[graphql-prisma] registering scalar ${name}`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import SchemaBuilder, { type SchemaTypes } from '@pothos/core';\nimport PrismaPlugin, { type PrismaClient } from '@pothos/plugin-prisma';\nimport ComplexityPlugin from '@pothos/plugin-complexity';\nimport DataloaderPlugin from '@pothos/plugin-dataloader';\nimport RelayPlugin from '@pothos/plugin-relay';\nimport TracingPlugin, {\n isRootField,\n wrapResolver,\n} from '@pothos/plugin-tracing';\nimport '@pothos/plugin-prisma';\nimport '@pothos/plugin-relay';\nimport '@pothos/plugin-complexity';\nimport { GeoJSONResolver } from 'graphql-scalars';\nimport { ScalarTypeEnum } from '@lssm/lib.schema';\n\nexport interface PrismaBuilderOptions {\n complexity?: {\n defaultComplexity?: number;\n defaultListMultiplier?: number;\n };\n tracing?: {\n enableByDefault?: boolean;\n onResolved?: (\n parentType: string,\n fieldName: string,\n durationMs: number\n ) => void;\n };\n federation?: boolean;\n prisma: {\n client: PrismaClient;\n dmmf?: {\n datamodel: unknown;\n };\n exposeDescriptions?: boolean;\n filterConnectionTotalCount?: boolean;\n onUnusedQuery?: 'warn' | null;\n };\n}\n\nexport function createPrismaSchemaBuilder<\n C extends object,\n PT extends {} | undefined,\n Objects extends object = object,\n Scalars extends object = object,\n>(options: PrismaBuilderOptions) {\n const debugBuilder =\n process.env.CONTRACTSPEC_DEBUG_GRAPHQL_BUILDER === 'true';\n // const plugins: (keyof PothosSchemaTypes.Plugins<SchemaTypes>)[] = [\n const plugins = [\n RelayPlugin,\n ComplexityPlugin,\n TracingPlugin,\n DataloaderPlugin,\n PrismaPlugin,\n ] satisfies (keyof PothosSchemaTypes.Plugins<SchemaTypes>)[];\n // if (options.federation) plugins.push(FederationPlugin);\n\n const builder = new SchemaBuilder<{\n DefaultInputFieldRequiredness: true;\n PrismaTypes: PT;\n Context: C;\n Objects: Objects;\n Scalars: {\n JSON: { Input: unknown; Output: unknown };\n Date: { Input: Date; Output: Date };\n EmailAddress: { Input: string; Output: string };\n Locale: { Input: string; Output: string };\n URL: { Input: string; Output: string };\n GeoJSON: { Input: string; Output: string };\n } & Scalars;\n ObjectType: { CommunityRule: { id: string } };\n }>({\n defaultInputFieldRequiredness: true,\n plugins,\n relay: {},\n prisma: {\n client: options.prisma.client,\n // ...(options.prisma.dmmf ? { dmmf: options.prisma.dmmf as any } : {}),\n dmmf: (options.prisma.dmmf as any) || {},\n exposeDescriptions: options.prisma.exposeDescriptions ?? true,\n filterConnectionTotalCount:\n options.prisma.filterConnectionTotalCount ?? true,\n onUnusedQuery: options.prisma.onUnusedQuery ?? null,\n },\n complexity: {\n defaultComplexity: options.complexity?.defaultComplexity ?? 1,\n defaultListMultiplier: options.complexity?.defaultListMultiplier ?? 10,\n },\n tracing: {\n default: (cfg) =>\n (options.tracing?.enableByDefault ?? true) ? isRootField(cfg) : false,\n wrap: (resolver, _opts, cfg) =>\n wrapResolver(resolver, (_err, dur) => {\n options.tracing?.onResolved?.(cfg.parentType, cfg.name, dur);\n }),\n },\n });\n\n if (debugBuilder) {\n console.log('[graphql-prisma] initializing schema builder');\n }\n\n Object.entries(ScalarTypeEnum).forEach(([name, type]) => {\n if (['ID', 'Boolean'].includes(name)) {\n return;\n }\n if (typeof type !== 'function') {\n throw new Error(\n `ScalarTypeEnum entry \"${name}\" must be a function but received ${typeof type}`\n );\n }\n if (debugBuilder) {\n console.log(`[graphql-prisma] registering scalar ${name}`);\n }\n builder.addScalarType(name as any, type());\n });\n builder.addScalarType('GeoJSON', GeoJSONResolver);\n\n builder.queryType({\n fields: (t) => ({}),\n });\n\n // Mutation Type (reduced, moved fields into modules)\n builder.mutationType({\n fields: (t) => ({}),\n });\n\n if (debugBuilder) {\n console.log('[graphql-prisma] schema builder ready');\n }\n\n return builder;\n}\n\n// export async function loadDmmfFromClient(\n// client: any\n// ): Promise<PrismaDMMF.Document> {\n// const dmmf: PrismaDMMF.Document | undefined = (client as any)?._dmmf;\n// if (dmmf) return dmmf;\n// if (typeof (client as any).$extends === 'function') {\n// const ext = await (client as any).$extends({});\n// if (ext && ext._dmmf) return ext._dmmf as PrismaDMMF.Document;\n// }\n// throw new Error('Unable to load Prisma DMMF from client');\n// }\n\n// export type PrismaSchemaBuilder<\n// C extends object,\n// PT extends {} | undefined,\n// > = PothosSchemaTypes.SchemaBuilder<\n// PothosSchemaTypes.ExtendDefaultTypes<{\n// PrismaTypes: PT;\n// Context: C;\n// Scalars: {\n// JSON: { Input: unknown; Output: unknown };\n// Date: { Input: Date; Output: Date };\n// };\n// }>\n// >;\n\n// export type PrismaSchemaBuilder<C, PT> = InstanceType<typeof SchemaBuilder><{\n// PrismaTypes: PT;\n// Context: C;\n// Scalars: {\n// JSON: { Input: unknown; Output: unknown };\n// Date: { Input: Date; Output: Date };\n// };\n// }>;\n\n// export function createTypedPrismaBuilder<PT extends {}>() {\n// return function create<C extends object>(options: PrismaBuilderOptions<C>) {\n// return createPrismaSchemaBuilder<C, PT>(options);\n// };\n// }\n\n// Tracing helper that integrates with a logger-like object\nexport interface LoggerLike {\n info: (msg: string, meta?: unknown) => void;\n}\nexport function createLoggerTracing(logger: LoggerLike, opLabel = 'gql.field') {\n return {\n enableByDefault: true,\n onResolved: (\n parentType: string,\n fieldName: string,\n durationMs: number,\n ...others: any[]\n ) => {\n // logger.info(opLabel, { parentType, fieldName, durationMs, others });\n },\n } as PrismaBuilderOptions['tracing'];\n}\n"],"mappings":";;;;;;;;;;AAwCA,SAAgB,0BAKd,SAA+B;CAC/B,MAAM,eACJ,QAAQ,IAAI,uCAAuC;CAWrD,MAAM,UAAU,IAAI,cAcjB;EACD,+BAA+B;EAC/B,SAzBc;GACd;GACA;GACA;GACA;GACA;GACD;EAoBC,OAAO,EAAE;EACT,QAAQ;GACN,QAAQ,QAAQ,OAAO;GAEvB,MAAO,QAAQ,OAAO,QAAgB,EAAE;GACxC,oBAAoB,QAAQ,OAAO,sBAAsB;GACzD,4BACE,QAAQ,OAAO,8BAA8B;GAC/C,eAAe,QAAQ,OAAO,iBAAiB;GAChD;EACD,YAAY;GACV,mBAAmB,QAAQ,YAAY,qBAAqB;GAC5D,uBAAuB,QAAQ,YAAY,yBAAyB;GACrE;EACD,SAAS;GACP,UAAU,QACP,QAAQ,SAAS,mBAAmB,OAAQ,YAAY,IAAI,GAAG;GAClE,OAAO,UAAU,OAAO,QACtB,aAAa,WAAW,MAAM,QAAQ;AACpC,YAAQ,SAAS,aAAa,IAAI,YAAY,IAAI,MAAM,IAAI;KAC5D;GACL;EACF,CAAC;AAEF,KAAI,aACF,SAAQ,IAAI,+CAA+C;AAG7D,QAAO,QAAQ,eAAe,CAAC,SAAS,CAAC,MAAM,UAAU;AACvD,MAAI,CAAC,MAAM,UAAU,CAAC,SAAS,KAAK,CAClC;AAEF,MAAI,OAAO,SAAS,WAClB,OAAM,IAAI,MACR,yBAAyB,KAAK,oCAAoC,OAAO,OAC1E;AAEH,MAAI,aACF,SAAQ,IAAI,uCAAuC,OAAO;AAE5D,UAAQ,cAAc,MAAa,MAAM,CAAC;GAC1C;AACF,SAAQ,cAAc,WAAW,gBAAgB;AAEjD,SAAQ,UAAU,EAChB,SAAS,OAAO,EAAE,GACnB,CAAC;AAGF,SAAQ,aAAa,EACnB,SAAS,OAAO,EAAE,GACnB,CAAC;AAEF,KAAI,aACF,SAAQ,IAAI,wCAAwC;AAGtD,QAAO;;AAgDT,SAAgB,oBAAoB,QAAoB,UAAU,aAAa;AAC7E,QAAO;EACL,iBAAiB;EACjB,aACE,YACA,WACA,YACA,GAAG,WACA;EAGN"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/lib.graphql-prisma",
|
|
3
|
-
"version": "0.0.0-canary-
|
|
3
|
+
"version": "0.0.0-canary-20251223010757",
|
|
4
4
|
"description": "Pothos + Prisma builder factory with injectable client/DMMF",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"clean": "rm -rf dist"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@lssm/lib.schema": "0.0.0-canary-
|
|
19
|
+
"@lssm/lib.schema": "0.0.0-canary-20251223010757",
|
|
20
20
|
"@pothos/core": "^4.9.1",
|
|
21
21
|
"@pothos/plugin-complexity": "^4.1.2",
|
|
22
22
|
"@pothos/plugin-dataloader": "^4.4.2",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"graphql": ">=16.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@lssm/tool.typescript": "0.0.0-canary-
|
|
34
|
-
"@lssm/tool.tsdown": "0.0.0-canary-
|
|
33
|
+
"@lssm/tool.typescript": "0.0.0-canary-20251223010757",
|
|
34
|
+
"@lssm/tool.tsdown": "0.0.0-canary-20251223010757",
|
|
35
35
|
"tsdown": "^0.18.1",
|
|
36
36
|
"typescript": "^5.9.3"
|
|
37
37
|
},
|