@lssm/lib.graphql-federation 0.0.0-canary-20251120170226
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 +33 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @lssm/lib.graphql-federation
|
|
2
|
+
|
|
3
|
+
GraphQL Federation utilities for Pothos.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
To enable Apollo Federation support for Pothos schemas. This package configures the `@pothos/plugin-federation` and provides helpers for defining entities and resolving references.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @lssm/lib.graphql-federation
|
|
13
|
+
# or
|
|
14
|
+
bun add @lssm/lib.graphql-federation
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Key Concepts
|
|
18
|
+
|
|
19
|
+
- **Federation**: Apollo Federation V2 support.
|
|
20
|
+
- **Entities**: defining `key` fields and `resolveReference` methods.
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { builder } from '@lssm/lib.graphql-core';
|
|
26
|
+
import '@lssm/lib.graphql-federation'; // Side-effect import to register plugin if needed, or use factory
|
|
27
|
+
|
|
28
|
+
builder.asEntity(User, {
|
|
29
|
+
key: builder.selection<{ id: string }>('id'),
|
|
30
|
+
resolveReference: (ref) => getUser(ref.id),
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SchemaTypes } from "@pothos/core";
|
|
2
|
+
import "@pothos/plugin-federation";
|
|
3
|
+
import { GraphQLSchema } from "graphql";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
6
|
+
declare function toSubgraphSDL(schema: GraphQLSchema): string;
|
|
7
|
+
declare function withEntityObject<T extends SchemaTypes>(builder: PothosSchemaTypes.SchemaBuilder<T>, name: string, keyFields: string[], fields: (t: any) => Record<string, any>, resolveReference: (ref: any, ctx: any) => Promise<any> | any): any;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { toSubgraphSDL, withEntityObject };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;iBAKgB,aAAA,SAAsB;iBAItB,2BAA2B,sBAChC,iBAAA,CAAkB,cAAc,2DAGrB,+DACsB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"@pothos/core";import"@pothos/plugin-federation";import{printSubgraphSchema as e}from"@apollo/subgraph";function t(t){return e(t)}function n(e,t,n,r,i){let a=e.objectRef(t);return a.implement({fields:r}),e.entity(t,{key:n.join(` `),resolveReference:i}),a}export{t as toSubgraphSDL,n as withEntityObject};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { type SchemaTypes } from '@pothos/core';\nimport '@pothos/plugin-federation';\nimport { printSubgraphSchema } from '@apollo/subgraph';\nimport type { GraphQLSchema } from 'graphql';\n\nexport function toSubgraphSDL(schema: GraphQLSchema) {\n return printSubgraphSchema(schema);\n}\n\nexport function withEntityObject<T extends SchemaTypes>(\n builder: PothosSchemaTypes.SchemaBuilder<T>,\n name: string,\n keyFields: string[],\n fields: (t: any) => Record<string, any>,\n resolveReference: (ref: any, ctx: any) => Promise<any> | any\n) {\n const ref = (builder as any).objectRef(name);\n ref.implement({\n fields,\n });\n (builder as any).entity(name, {\n key: keyFields.join(' '),\n resolveReference,\n });\n return ref;\n}\n"],"mappings":"8GAKA,SAAgB,EAAc,EAAuB,CACnD,OAAO,EAAoB,EAAO,CAGpC,SAAgB,EACd,EACA,EACA,EACA,EACA,EACA,CACA,IAAM,EAAO,EAAgB,UAAU,EAAK,CAQ5C,OAPA,EAAI,UAAU,CACZ,SACD,CAAC,CACD,EAAgB,OAAO,EAAM,CAC5B,IAAK,EAAU,KAAK,IAAI,CACxB,mBACD,CAAC,CACK"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lssm/lib.graphql-federation",
|
|
3
|
+
"version": "0.0.0-canary-20251120170226",
|
|
4
|
+
"description": "Pothos federation helpers and subgraph schema export utilities",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsdown",
|
|
13
|
+
"dev": "tsup --watch",
|
|
14
|
+
"clean": "rm -rf dist"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@pothos/core": "^4.9.1",
|
|
18
|
+
"@pothos/plugin-federation": "^4.0.0",
|
|
19
|
+
"@pothos/plugin-directives": "^4.2.3",
|
|
20
|
+
"graphql": "^16.8.1",
|
|
21
|
+
"@apollo/subgraph": "^2.8.0"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"graphql": ">=16.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@lssm/tool.tsdown": "0.0.0-canary-20251120170226",
|
|
28
|
+
"tsdown": "^0.15.9",
|
|
29
|
+
"typescript": "^5.9.3"
|
|
30
|
+
},
|
|
31
|
+
"type": "module",
|
|
32
|
+
"module": "./dist/index.js",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./dist/index.js",
|
|
35
|
+
"./*": "./*"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"exports": {
|
|
39
|
+
".": "./dist/index.js",
|
|
40
|
+
"./*": "./*"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|