@lssm/lib.graphql-core 1.11.1 → 1.41.1
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/README.md +5 -0
- package/dist/index.js +1 -2
- package/package.json +6 -5
- package/dist/index.d.ts +0 -34
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
import e from"@pothos/core";import t from"@pothos/plugin-complexity";import n from"@pothos/plugin-dataloader";import r from"@pothos/plugin-relay";import i,{isRootField as a,wrapResolver as o}from"@pothos/plugin-tracing";import{DateResolver as s,JSONResolver as c}from"graphql-scalars";function l(l){let u=new e({plugins:[r,t,i,n],complexity:{defaultComplexity:l.complexity?.defaultComplexity??1,defaultListMultiplier:l.complexity?.defaultListMultiplier??10},tracing:{default:e=>l.tracing?.enableByDefault??!0?a(e):!1,wrap:(e,t,n)=>o(e,(e,t)=>{l.tracing?.onResolved?.(n.parentType,n.name,t)})}});return u.addScalarType(`JSON`,c),u.addScalarType(`Date`,s),u}const u=e=>()=>e,d=(e,t=10)=>(n,r)=>e+t*r;function f(e,t=`gql.field`){return{enableByDefault:!0,onResolved:(n,r,i)=>{e.info(t,{parentType:n,fieldName:r,durationMs:i})}}}export{u as complexity,f as createLoggerTracing,l as createSchemaBuilder,d as listComplexity};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import e from"@pothos/core";import t from"@pothos/plugin-complexity";import n from"@pothos/plugin-dataloader";import r from"@pothos/plugin-relay";import i,{isRootField as a,wrapResolver as o}from"@pothos/plugin-tracing";import{DateResolver as s,JSONResolver as c}from"graphql-scalars";function l(l){let u=new e({plugins:[r,t,i,n],complexity:{defaultComplexity:l.complexity?.defaultComplexity??1,defaultListMultiplier:l.complexity?.defaultListMultiplier??10},tracing:{default:e=>l.tracing?.enableByDefault??!0?a(e):!1,wrap:(e,t,n)=>o(e,(e,t)=>{l.tracing?.onResolved?.(n.parentType,n.name,t)})}});return u.addScalarType(`JSON`,c),u.addScalarType(`Date`,s),u}const u=e=>()=>e,d=(e,t=10)=>(n,r)=>e+t*r;function f(e,t=`gql.field`){return{enableByDefault:!0,onResolved:(n,r,i)=>{e.info(t,{parentType:n,fieldName:r,durationMs:i})}}}export{u as complexity,f as createLoggerTracing,l as createSchemaBuilder,d as listComplexity};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lssm/lib.graphql-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.1",
|
|
4
4
|
"description": "Shared GraphQL core: Pothos builder factory, scalars, tracing & complexity",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
],
|
|
11
11
|
"scripts": {
|
|
12
12
|
"publish:pkg": "bun publish --tolerate-republish --ignore-scripts --verbose",
|
|
13
|
+
"publish:pkg:canary": "bun publish:pkg --tag canary",
|
|
13
14
|
"build": "tsdown",
|
|
14
15
|
"dev": "tsup --watch",
|
|
15
16
|
"clean": "rm -rf dist"
|
|
@@ -27,15 +28,15 @@
|
|
|
27
28
|
"graphql": ">=16.0.0"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"@lssm/tool.typescript": "
|
|
31
|
-
"@lssm/tool.tsdown": "
|
|
32
|
-
"tsdown": "^0.
|
|
31
|
+
"@lssm/tool.typescript": "1.41.1",
|
|
32
|
+
"@lssm/tool.tsdown": "1.41.1",
|
|
33
|
+
"tsdown": "^0.17.4",
|
|
33
34
|
"typescript": "^5.9.3"
|
|
34
35
|
},
|
|
35
36
|
"type": "module",
|
|
36
37
|
"module": "./dist/index.js",
|
|
37
38
|
"exports": {
|
|
38
|
-
".": "./
|
|
39
|
+
".": "./src/index.ts",
|
|
39
40
|
"./*": "./*"
|
|
40
41
|
},
|
|
41
42
|
"publishConfig": {
|
package/dist/index.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
//#region src/index.d.ts
|
|
2
|
-
interface CreateBuilderOptions<C> {
|
|
3
|
-
contextType: C;
|
|
4
|
-
complexity?: {
|
|
5
|
-
defaultComplexity?: number;
|
|
6
|
-
defaultListMultiplier?: number;
|
|
7
|
-
};
|
|
8
|
-
tracing?: {
|
|
9
|
-
enableByDefault?: boolean;
|
|
10
|
-
onResolved?: (parentType: string, fieldName: string, durationMs: number) => void;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
declare function createSchemaBuilder<C extends {}>(options: CreateBuilderOptions<C>): PothosSchemaTypes.SchemaBuilder<PothosSchemaTypes.ExtendDefaultTypes<{
|
|
14
|
-
Context: C;
|
|
15
|
-
Scalars: {
|
|
16
|
-
JSON: {
|
|
17
|
-
Input: unknown;
|
|
18
|
-
Output: unknown;
|
|
19
|
-
};
|
|
20
|
-
Date: {
|
|
21
|
-
Input: Date;
|
|
22
|
-
Output: Date;
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
}>>;
|
|
26
|
-
declare const complexity: (value: number) => () => number;
|
|
27
|
-
declare const listComplexity: (base: number, multiplier?: number) => (_args: unknown, childComplexity: number) => number;
|
|
28
|
-
interface LoggerLike {
|
|
29
|
-
info: (msg: string, meta?: unknown) => void;
|
|
30
|
-
}
|
|
31
|
-
declare function createLoggerTracing(logger: LoggerLike, opLabel?: string): CreateBuilderOptions<unknown>["tracing"];
|
|
32
|
-
//#endregion
|
|
33
|
-
export { CreateBuilderOptions, LoggerLike, complexity, createLoggerTracing, createSchemaBuilder, listComplexity };
|
|
34
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";UAUiB;EAAA,WAAA,EACF,CADE;EAgBD,UAAA,CAAA,EAAA;IACgB,iBAAA,CAAA,EAAA,MAAA;IAArB,qBAAA,CAAA,EAAA,MAAA;EAGE,CAAA;EAGQ,OAAA,CAAA,EAAA;IAAc,eAAA,CAAA,EAAA,OAAA;IAND,UAAA,CAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,GAAA,IAAA;EAAA,CAAA;;AA+BrB,iBAhCG,mBAgCwC,CAAA,UAAA,CAAA,CAAA,CAAA,CAAA,OAAA,EA/B7C,oBA+B6C,CA/BxB,CA+BwB,CAAA,CAAA,EA/BtB,iBAAA,CAAA,aA+BsB,CA/BtB,iBAAA,CAAA,kBA+BsB,CAAA;EAC3C,OAAA,EA7BA,CA6BA;EAMI,OAAA,EAAA;IAGD,IAAA,EAAA;;;;;aAnCK;cAAc;;;;cAyBtB;cACA;UAMI,UAAA;;;iBAGD,mBAAA,SAA4B,+BAMrC"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import SchemaBuilder from '@pothos/core';\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 { DateResolver, JSONResolver } from 'graphql-scalars';\n\nexport interface CreateBuilderOptions<C> {\n contextType: C;\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}\n\nexport function createSchemaBuilder<C extends {}>(\n options: CreateBuilderOptions<C>\n) {\n const builder = new SchemaBuilder<{\n Context: C;\n Scalars: {\n JSON: { Input: unknown; Output: unknown };\n Date: { Input: Date; Output: Date };\n };\n }>({\n plugins: [RelayPlugin, ComplexityPlugin, TracingPlugin, DataloaderPlugin],\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 builder.addScalarType('JSON', JSONResolver);\n builder.addScalarType('Date', DateResolver);\n\n return builder as typeof builder;\n}\n\n// Complexity helpers for consistent usage in field definitions\nexport const complexity = (value: number) => () => value;\nexport const listComplexity =\n (base: number, multiplier = 10) =>\n (_args: unknown, childComplexity: number) =>\n base + multiplier * childComplexity;\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: (parentType: string, fieldName: string, durationMs: number) => {\n logger.info(opLabel, { parentType, fieldName, durationMs });\n },\n } as CreateBuilderOptions<unknown>['tracing'];\n}\n"],"mappings":"6RA0BA,SAAgB,EACd,EACA,CACA,IAAM,EAAU,IAAI,EAMjB,CACD,QAAS,CAAC,EAAa,EAAkB,EAAe,EAAiB,CACzE,WAAY,CACV,kBAAmB,EAAQ,YAAY,mBAAqB,EAC5D,sBAAuB,EAAQ,YAAY,uBAAyB,GACrE,CACD,QAAS,CACP,QAAU,GACP,EAAQ,SAAS,iBAAmB,GAAQ,EAAY,EAAI,CAAG,GAClE,MAAO,EAAU,EAAO,IACtB,EAAa,GAAW,EAAM,IAAQ,CACpC,EAAQ,SAAS,aAAa,EAAI,WAAY,EAAI,KAAM,EAAI,EAC5D,CACL,CACF,CAAC,CAKF,OAHA,EAAQ,cAAc,OAAQ,EAAa,CAC3C,EAAQ,cAAc,OAAQ,EAAa,CAEpC,EAIT,MAAa,EAAc,OAAwB,EACtC,GACV,EAAc,EAAa,MAC3B,EAAgB,IACf,EAAO,EAAa,EAMxB,SAAgB,EAAoB,EAAoB,EAAU,YAAa,CAC7E,MAAO,CACL,gBAAiB,GACjB,YAAa,EAAoB,EAAmB,IAAuB,CACzE,EAAO,KAAK,EAAS,CAAE,aAAY,YAAW,aAAY,CAAC,EAE9D"}
|