@contractspec/lib.graphql-prisma 1.57.0 → 1.59.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.
@@ -0,0 +1,83 @@
1
+ // src/index.ts
2
+ import SchemaBuilder from "@pothos/core";
3
+ import PrismaPlugin from "@pothos/plugin-prisma";
4
+ import ComplexityPlugin from "@pothos/plugin-complexity";
5
+ import DataloaderPlugin from "@pothos/plugin-dataloader";
6
+ import RelayPlugin from "@pothos/plugin-relay";
7
+ import TracingPlugin, {
8
+ isRootField,
9
+ wrapResolver
10
+ } from "@pothos/plugin-tracing";
11
+ import"@pothos/plugin-prisma";
12
+ import"@pothos/plugin-relay";
13
+ import"@pothos/plugin-complexity";
14
+ import { GeoJSONResolver } from "graphql-scalars";
15
+ import { ScalarTypeEnum } from "@contractspec/lib.schema";
16
+ function createPrismaSchemaBuilder(options) {
17
+ const debugBuilder = process.env.CONTRACTSPEC_DEBUG_GRAPHQL_BUILDER === "true";
18
+ const plugins = [
19
+ RelayPlugin,
20
+ ComplexityPlugin,
21
+ TracingPlugin,
22
+ DataloaderPlugin,
23
+ PrismaPlugin
24
+ ];
25
+ const builder = new SchemaBuilder({
26
+ defaultInputFieldRequiredness: true,
27
+ plugins,
28
+ relay: {},
29
+ prisma: {
30
+ client: options.prisma.client,
31
+ dmmf: options.prisma.dmmf || {},
32
+ exposeDescriptions: options.prisma.exposeDescriptions ?? true,
33
+ filterConnectionTotalCount: options.prisma.filterConnectionTotalCount ?? true,
34
+ onUnusedQuery: options.prisma.onUnusedQuery ?? null
35
+ },
36
+ complexity: {
37
+ defaultComplexity: options.complexity?.defaultComplexity ?? 1,
38
+ defaultListMultiplier: options.complexity?.defaultListMultiplier ?? 10
39
+ },
40
+ tracing: {
41
+ default: (cfg) => options.tracing?.enableByDefault ?? true ? isRootField(cfg) : false,
42
+ wrap: (resolver, _opts, cfg) => wrapResolver(resolver, (_err, dur) => {
43
+ options.tracing?.onResolved?.(cfg.parentType, cfg.name, dur);
44
+ })
45
+ }
46
+ });
47
+ if (debugBuilder) {
48
+ console.log("[graphql-prisma] initializing schema builder");
49
+ }
50
+ Object.entries(ScalarTypeEnum).forEach(([name, type]) => {
51
+ if (["ID", "Boolean"].includes(name)) {
52
+ return;
53
+ }
54
+ if (typeof type !== "function") {
55
+ throw new Error(`ScalarTypeEnum entry "${name}" must be a function but received ${typeof type}`);
56
+ }
57
+ if (debugBuilder) {
58
+ console.log(`[graphql-prisma] registering scalar ${name}`);
59
+ }
60
+ builder.addScalarType(name, type());
61
+ });
62
+ builder.addScalarType("GeoJSON", GeoJSONResolver);
63
+ builder.queryType({
64
+ fields: (t) => ({})
65
+ });
66
+ builder.mutationType({
67
+ fields: (t) => ({})
68
+ });
69
+ if (debugBuilder) {
70
+ console.log("[graphql-prisma] schema builder ready");
71
+ }
72
+ return builder;
73
+ }
74
+ function createLoggerTracing(logger, opLabel = "gql.field") {
75
+ return {
76
+ enableByDefault: true,
77
+ onResolved: (parentType, fieldName, durationMs, ...others) => {}
78
+ };
79
+ }
80
+ export {
81
+ createPrismaSchemaBuilder,
82
+ createLoggerTracing
83
+ };
package/dist/index.d.ts CHANGED
@@ -1,69 +1,66 @@
1
- import { PrismaClient } from "@pothos/plugin-prisma";
2
- import "@pothos/plugin-complexity";
3
- import "@pothos/plugin-relay";
4
-
5
- //#region src/index.d.ts
6
- interface PrismaBuilderOptions {
7
- complexity?: {
8
- defaultComplexity?: number;
9
- defaultListMultiplier?: number;
10
- };
11
- tracing?: {
12
- enableByDefault?: boolean;
13
- onResolved?: (parentType: string, fieldName: string, durationMs: number) => void;
14
- };
15
- federation?: boolean;
16
- prisma: {
17
- client: PrismaClient;
18
- dmmf?: {
19
- datamodel: unknown;
1
+ import { type PrismaClient } from '@pothos/plugin-prisma';
2
+ import '@pothos/plugin-prisma';
3
+ import '@pothos/plugin-relay';
4
+ import '@pothos/plugin-complexity';
5
+ export interface PrismaBuilderOptions {
6
+ complexity?: {
7
+ defaultComplexity?: number;
8
+ defaultListMultiplier?: number;
20
9
  };
21
- exposeDescriptions?: boolean;
22
- filterConnectionTotalCount?: boolean;
23
- onUnusedQuery?: 'warn' | null;
24
- };
25
- }
26
- declare function createPrismaSchemaBuilder<C extends object, PT extends {} | undefined, Objects extends object = object, Scalars extends object = object>(options: PrismaBuilderOptions): PothosSchemaTypes.SchemaBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
27
- DefaultInputFieldRequiredness: true;
28
- PrismaTypes: PT;
29
- Context: C;
30
- Objects: Objects;
31
- Scalars: {
32
- JSON: {
33
- Input: unknown;
34
- Output: unknown;
35
- };
36
- Date: {
37
- Input: Date;
38
- Output: Date;
39
- };
40
- EmailAddress: {
41
- Input: string;
42
- Output: string;
10
+ tracing?: {
11
+ enableByDefault?: boolean;
12
+ onResolved?: (parentType: string, fieldName: string, durationMs: number) => void;
43
13
  };
44
- Locale: {
45
- Input: string;
46
- Output: string;
14
+ federation?: boolean;
15
+ prisma: {
16
+ client: PrismaClient;
17
+ dmmf?: {
18
+ datamodel: unknown;
19
+ };
20
+ exposeDescriptions?: boolean;
21
+ filterConnectionTotalCount?: boolean;
22
+ onUnusedQuery?: 'warn' | null;
47
23
  };
48
- URL: {
49
- Input: string;
50
- Output: string;
51
- };
52
- GeoJSON: {
53
- Input: string;
54
- Output: string;
55
- };
56
- } & Scalars;
57
- ObjectType: {
58
- CommunityRule: {
59
- id: string;
24
+ }
25
+ export declare function createPrismaSchemaBuilder<C extends object, PT extends {} | undefined, Objects extends object = object, Scalars extends object = object>(options: PrismaBuilderOptions): PothosSchemaTypes.SchemaBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
26
+ DefaultInputFieldRequiredness: true;
27
+ PrismaTypes: PT;
28
+ Context: C;
29
+ Objects: Objects;
30
+ Scalars: {
31
+ JSON: {
32
+ Input: unknown;
33
+ Output: unknown;
34
+ };
35
+ Date: {
36
+ Input: Date;
37
+ Output: Date;
38
+ };
39
+ EmailAddress: {
40
+ Input: string;
41
+ Output: string;
42
+ };
43
+ Locale: {
44
+ Input: string;
45
+ Output: string;
46
+ };
47
+ URL: {
48
+ Input: string;
49
+ Output: string;
50
+ };
51
+ GeoJSON: {
52
+ Input: string;
53
+ Output: string;
54
+ };
55
+ } & Scalars;
56
+ ObjectType: {
57
+ CommunityRule: {
58
+ id: string;
59
+ };
60
60
  };
61
- };
62
61
  }>>;
63
- interface LoggerLike {
64
- info: (msg: string, meta?: unknown) => void;
62
+ export interface LoggerLike {
63
+ info: (msg: string, meta?: unknown) => void;
65
64
  }
66
- declare function createLoggerTracing(logger: LoggerLike, opLabel?: string): PrismaBuilderOptions["tracing"];
67
- //#endregion
68
- export { LoggerLike, PrismaBuilderOptions, createLoggerTracing, createPrismaSchemaBuilder };
65
+ export declare function createLoggerTracing(logger: LoggerLike, opLabel?: string): PrismaBuilderOptions["tracing"];
69
66
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;UAeiB,oBAAA;EACf,UAAA;IACE,iBAAA;IACA,qBAAA;EAAA;EAEF,OAAA;IACE,eAAA;IACA,UAAA,IACE,UAAA,UACA,SAAA,UACA,UAAA;EAAA;EAGJ,UAAA;EACA,MAAA;IACE,MAAA,EAAQ,YAAA;IACR,IAAA;MACE,SAAA;IAAA;IAEF,kBAAA;IACA,0BAAA;IACA,aAAA;EAAA;AAAA;AAAA,iBAIY,yBAAA,+GAAA,CAKd,OAAA,EAAS,oBAAA,GAAoB,iBAAA,CAAA,aAAA,CAAA,iBAAA,CAAA,kBAAA;;eAed,EAAA;WACJ,CAAA;WACA,OAAA;;IAEP,IAAA;MAAQ,KAAA;MAAgB,MAAA;IAAA;IACxB,IAAA;MAAQ,KAAA,EAAO,IAAA;MAAM,MAAA,EAAQ,IAAA;IAAA;IAC7B,YAAA;MAAgB,KAAA;MAAe,MAAA;IAAA;IAC/B,MAAA;MAAU,KAAA;MAAe,MAAA;IAAA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AAS,MAAM,GAAG,MAAM,EAC/B,OAAO,EAAE,oBAAoB;mCAcI,IAAI;iBACtB,EAAE;aACN,CAAC;aACD,OAAO;aACP;QACP,IAAI,EAAE;YAAE,KAAK,EAAE,OAAO,CAAC;YAAC,MAAM,EAAE,OAAO,CAAA;SAAE,CAAC;QAC1C,IAAI,EAAE;YAAE,KAAK,EAAE,IAAI,CAAC;YAAC,MAAM,EAAE,IAAI,CAAA;SAAE,CAAC;QACpC,YAAY,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QAChD,MAAM,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QAC1C,GAAG,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;QACvC,OAAO,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,CAAC;KAC5C,GAAG,OAAO;gBACC;QAAE,aAAa,EAAE;YAAE,EAAE,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE;IA8DhD;AA4CD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7C;AACD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,SAAc,GAWtE,oBAAoB,CAAC,SAAS,CAAC,CACrC"}
package/dist/index.js CHANGED
@@ -1,63 +1,84 @@
1
+ // @bun
2
+ // src/index.ts
1
3
  import SchemaBuilder from "@pothos/core";
2
4
  import PrismaPlugin from "@pothos/plugin-prisma";
3
5
  import ComplexityPlugin from "@pothos/plugin-complexity";
4
6
  import DataloaderPlugin from "@pothos/plugin-dataloader";
5
7
  import RelayPlugin from "@pothos/plugin-relay";
6
- import TracingPlugin, { isRootField, wrapResolver } from "@pothos/plugin-tracing";
8
+ import TracingPlugin, {
9
+ isRootField,
10
+ wrapResolver
11
+ } from "@pothos/plugin-tracing";
12
+ import"@pothos/plugin-prisma";
13
+ import"@pothos/plugin-relay";
14
+ import"@pothos/plugin-complexity";
7
15
  import { GeoJSONResolver } from "graphql-scalars";
8
16
  import { ScalarTypeEnum } from "@contractspec/lib.schema";
9
-
10
- //#region src/index.ts
11
17
  function createPrismaSchemaBuilder(options) {
12
- const debugBuilder = process.env.CONTRACTSPEC_DEBUG_GRAPHQL_BUILDER === "true";
13
- const builder = new SchemaBuilder({
14
- defaultInputFieldRequiredness: true,
15
- plugins: [
16
- RelayPlugin,
17
- ComplexityPlugin,
18
- TracingPlugin,
19
- DataloaderPlugin,
20
- PrismaPlugin
21
- ],
22
- relay: {},
23
- prisma: {
24
- client: options.prisma.client,
25
- dmmf: options.prisma.dmmf || {},
26
- exposeDescriptions: options.prisma.exposeDescriptions ?? true,
27
- filterConnectionTotalCount: options.prisma.filterConnectionTotalCount ?? true,
28
- onUnusedQuery: options.prisma.onUnusedQuery ?? null
29
- },
30
- complexity: {
31
- defaultComplexity: options.complexity?.defaultComplexity ?? 1,
32
- defaultListMultiplier: options.complexity?.defaultListMultiplier ?? 10
33
- },
34
- tracing: {
35
- default: (cfg) => options.tracing?.enableByDefault ?? true ? isRootField(cfg) : false,
36
- wrap: (resolver, _opts, cfg) => wrapResolver(resolver, (_err, dur) => {
37
- options.tracing?.onResolved?.(cfg.parentType, cfg.name, dur);
38
- })
39
- }
40
- });
41
- if (debugBuilder) console.log("[graphql-prisma] initializing schema builder");
42
- Object.entries(ScalarTypeEnum).forEach(([name, type]) => {
43
- if (["ID", "Boolean"].includes(name)) return;
44
- if (typeof type !== "function") throw new Error(`ScalarTypeEnum entry "${name}" must be a function but received ${typeof type}`);
45
- if (debugBuilder) console.log(`[graphql-prisma] registering scalar ${name}`);
46
- builder.addScalarType(name, type());
47
- });
48
- builder.addScalarType("GeoJSON", GeoJSONResolver);
49
- builder.queryType({ fields: (t) => ({}) });
50
- builder.mutationType({ fields: (t) => ({}) });
51
- if (debugBuilder) console.log("[graphql-prisma] schema builder ready");
52
- return builder;
18
+ const debugBuilder = process.env.CONTRACTSPEC_DEBUG_GRAPHQL_BUILDER === "true";
19
+ const plugins = [
20
+ RelayPlugin,
21
+ ComplexityPlugin,
22
+ TracingPlugin,
23
+ DataloaderPlugin,
24
+ PrismaPlugin
25
+ ];
26
+ const builder = new SchemaBuilder({
27
+ defaultInputFieldRequiredness: true,
28
+ plugins,
29
+ relay: {},
30
+ prisma: {
31
+ client: options.prisma.client,
32
+ dmmf: options.prisma.dmmf || {},
33
+ exposeDescriptions: options.prisma.exposeDescriptions ?? true,
34
+ filterConnectionTotalCount: options.prisma.filterConnectionTotalCount ?? true,
35
+ onUnusedQuery: options.prisma.onUnusedQuery ?? null
36
+ },
37
+ complexity: {
38
+ defaultComplexity: options.complexity?.defaultComplexity ?? 1,
39
+ defaultListMultiplier: options.complexity?.defaultListMultiplier ?? 10
40
+ },
41
+ tracing: {
42
+ default: (cfg) => options.tracing?.enableByDefault ?? true ? isRootField(cfg) : false,
43
+ wrap: (resolver, _opts, cfg) => wrapResolver(resolver, (_err, dur) => {
44
+ options.tracing?.onResolved?.(cfg.parentType, cfg.name, dur);
45
+ })
46
+ }
47
+ });
48
+ if (debugBuilder) {
49
+ console.log("[graphql-prisma] initializing schema builder");
50
+ }
51
+ Object.entries(ScalarTypeEnum).forEach(([name, type]) => {
52
+ if (["ID", "Boolean"].includes(name)) {
53
+ return;
54
+ }
55
+ if (typeof type !== "function") {
56
+ throw new Error(`ScalarTypeEnum entry "${name}" must be a function but received ${typeof type}`);
57
+ }
58
+ if (debugBuilder) {
59
+ console.log(`[graphql-prisma] registering scalar ${name}`);
60
+ }
61
+ builder.addScalarType(name, type());
62
+ });
63
+ builder.addScalarType("GeoJSON", GeoJSONResolver);
64
+ builder.queryType({
65
+ fields: (t) => ({})
66
+ });
67
+ builder.mutationType({
68
+ fields: (t) => ({})
69
+ });
70
+ if (debugBuilder) {
71
+ console.log("[graphql-prisma] schema builder ready");
72
+ }
73
+ return builder;
53
74
  }
54
75
  function createLoggerTracing(logger, opLabel = "gql.field") {
55
- return {
56
- enableByDefault: true,
57
- onResolved: (parentType, fieldName, durationMs, ...others) => {}
58
- };
76
+ return {
77
+ enableByDefault: true,
78
+ onResolved: (parentType, fieldName, durationMs, ...others) => {}
79
+ };
59
80
  }
60
-
61
- //#endregion
62
- export { createLoggerTracing, createPrismaSchemaBuilder };
63
- //# sourceMappingURL=index.js.map
81
+ export {
82
+ createPrismaSchemaBuilder,
83
+ createLoggerTracing
84
+ };
@@ -0,0 +1,83 @@
1
+ // src/index.ts
2
+ import SchemaBuilder from "@pothos/core";
3
+ import PrismaPlugin from "@pothos/plugin-prisma";
4
+ import ComplexityPlugin from "@pothos/plugin-complexity";
5
+ import DataloaderPlugin from "@pothos/plugin-dataloader";
6
+ import RelayPlugin from "@pothos/plugin-relay";
7
+ import TracingPlugin, {
8
+ isRootField,
9
+ wrapResolver
10
+ } from "@pothos/plugin-tracing";
11
+ import"@pothos/plugin-prisma";
12
+ import"@pothos/plugin-relay";
13
+ import"@pothos/plugin-complexity";
14
+ import { GeoJSONResolver } from "graphql-scalars";
15
+ import { ScalarTypeEnum } from "@contractspec/lib.schema";
16
+ function createPrismaSchemaBuilder(options) {
17
+ const debugBuilder = process.env.CONTRACTSPEC_DEBUG_GRAPHQL_BUILDER === "true";
18
+ const plugins = [
19
+ RelayPlugin,
20
+ ComplexityPlugin,
21
+ TracingPlugin,
22
+ DataloaderPlugin,
23
+ PrismaPlugin
24
+ ];
25
+ const builder = new SchemaBuilder({
26
+ defaultInputFieldRequiredness: true,
27
+ plugins,
28
+ relay: {},
29
+ prisma: {
30
+ client: options.prisma.client,
31
+ dmmf: options.prisma.dmmf || {},
32
+ exposeDescriptions: options.prisma.exposeDescriptions ?? true,
33
+ filterConnectionTotalCount: options.prisma.filterConnectionTotalCount ?? true,
34
+ onUnusedQuery: options.prisma.onUnusedQuery ?? null
35
+ },
36
+ complexity: {
37
+ defaultComplexity: options.complexity?.defaultComplexity ?? 1,
38
+ defaultListMultiplier: options.complexity?.defaultListMultiplier ?? 10
39
+ },
40
+ tracing: {
41
+ default: (cfg) => options.tracing?.enableByDefault ?? true ? isRootField(cfg) : false,
42
+ wrap: (resolver, _opts, cfg) => wrapResolver(resolver, (_err, dur) => {
43
+ options.tracing?.onResolved?.(cfg.parentType, cfg.name, dur);
44
+ })
45
+ }
46
+ });
47
+ if (debugBuilder) {
48
+ console.log("[graphql-prisma] initializing schema builder");
49
+ }
50
+ Object.entries(ScalarTypeEnum).forEach(([name, type]) => {
51
+ if (["ID", "Boolean"].includes(name)) {
52
+ return;
53
+ }
54
+ if (typeof type !== "function") {
55
+ throw new Error(`ScalarTypeEnum entry "${name}" must be a function but received ${typeof type}`);
56
+ }
57
+ if (debugBuilder) {
58
+ console.log(`[graphql-prisma] registering scalar ${name}`);
59
+ }
60
+ builder.addScalarType(name, type());
61
+ });
62
+ builder.addScalarType("GeoJSON", GeoJSONResolver);
63
+ builder.queryType({
64
+ fields: (t) => ({})
65
+ });
66
+ builder.mutationType({
67
+ fields: (t) => ({})
68
+ });
69
+ if (debugBuilder) {
70
+ console.log("[graphql-prisma] schema builder ready");
71
+ }
72
+ return builder;
73
+ }
74
+ function createLoggerTracing(logger, opLabel = "gql.field") {
75
+ return {
76
+ enableByDefault: true,
77
+ onResolved: (parentType, fieldName, durationMs, ...others) => {}
78
+ };
79
+ }
80
+ export {
81
+ createPrismaSchemaBuilder,
82
+ createLoggerTracing
83
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/lib.graphql-prisma",
3
- "version": "1.57.0",
3
+ "version": "1.59.0",
4
4
  "description": "Pothos + Prisma builder factory with injectable client/DMMF",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -18,12 +18,16 @@
18
18
  "scripts": {
19
19
  "publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
20
20
  "publish:pkg:canary": "bun publish:pkg --tag canary",
21
- "build": "tsdown",
22
- "dev": "tsup --watch",
23
- "clean": "rm -rf dist"
21
+ "build": "bun run prebuild && bun run build:bundle && bun run build:types",
22
+ "dev": "contractspec-bun-build dev",
23
+ "clean": "rm -rf dist",
24
+ "prebuild": "contractspec-bun-build prebuild",
25
+ "build:bundle": "contractspec-bun-build transpile",
26
+ "build:types": "contractspec-bun-build types",
27
+ "typecheck": "tsc --noEmit"
24
28
  },
25
29
  "dependencies": {
26
- "@contractspec/lib.schema": "1.57.0",
30
+ "@contractspec/lib.schema": "1.59.0",
27
31
  "@pothos/core": "^4.9.1",
28
32
  "@pothos/plugin-complexity": "^4.1.2",
29
33
  "@pothos/plugin-dataloader": "^4.4.2",
@@ -37,21 +41,24 @@
37
41
  "graphql": ">=16.0.0"
38
42
  },
39
43
  "devDependencies": {
40
- "@contractspec/tool.typescript": "1.57.0",
41
- "@contractspec/tool.tsdown": "1.57.0",
42
- "tsdown": "^0.20.3",
43
- "typescript": "^5.9.3"
44
+ "@contractspec/tool.typescript": "1.59.0",
45
+ "typescript": "^5.9.3",
46
+ "@contractspec/tool.bun": "1.58.0"
44
47
  },
45
48
  "type": "module",
46
49
  "exports": {
47
- ".": "./dist/index.js",
48
- "./*": "./*"
50
+ ".": "./src/index.ts"
49
51
  },
50
52
  "publishConfig": {
51
53
  "access": "public",
52
54
  "exports": {
53
- ".": "./dist/index.js",
54
- "./*": "./*"
55
+ ".": {
56
+ "types": "./dist/index.d.ts",
57
+ "bun": "./dist/index.js",
58
+ "node": "./dist/node/index.mjs",
59
+ "browser": "./dist/browser/index.js",
60
+ "default": "./dist/index.js"
61
+ }
55
62
  },
56
63
  "registry": "https://registry.npmjs.org/"
57
64
  },
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
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 '@contractspec/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,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