@wundergraph/composition 0.54.0 → 0.54.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 +24 -18
- package/dist/utils/composition-version.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -28,8 +28,6 @@ An example federation of two simple subgraphs:
|
|
|
28
28
|
import { federateSubgraphs, FederationResult, Subgraph } from '@wundergraph/composition';
|
|
29
29
|
import { parse } from 'graphql';
|
|
30
30
|
|
|
31
|
-
const result: FederationResult = federateSubgraphs([subgraphA, subgraphB]);
|
|
32
|
-
|
|
33
31
|
const subgraphA: Subgraph = {
|
|
34
32
|
name: 'subgraph-a',
|
|
35
33
|
url: 'http://localhost:4001',
|
|
@@ -48,39 +46,47 @@ const subgraphB: Subgraph = {
|
|
|
48
46
|
type Query {
|
|
49
47
|
users: [User!]!
|
|
50
48
|
}
|
|
51
|
-
|
|
49
|
+
|
|
52
50
|
type User @key(fields: "id") {
|
|
53
51
|
id: ID!
|
|
54
52
|
interests: [String!]!
|
|
55
53
|
}
|
|
56
54
|
`),
|
|
57
55
|
};
|
|
56
|
+
|
|
57
|
+
const result: FederationResult = federateSubgraphs({ subgraphs: [subgraphA, subgraphB] });
|
|
58
58
|
```
|
|
59
59
|
|
|
60
60
|
### FederationResult
|
|
61
61
|
|
|
62
|
-
The `federateSubgraphs` function returns `FederationResult`, which is a union of `
|
|
63
|
-
`
|
|
62
|
+
The `federateSubgraphs` function returns `FederationResult`, which is a union of `FederationSuccess` and
|
|
63
|
+
`FederationFailure`. Both types in the union always define the following mutual properties:
|
|
64
64
|
|
|
65
65
|
| property | Description | type |
|
|
66
66
|
| -------- | -------------------------------------- | -------------- |
|
|
67
67
|
| success | assertion of composition success | boolean |
|
|
68
68
|
| warnings | array of composition warnings (if any) | Array<Warning> |
|
|
69
69
|
|
|
70
|
-
####
|
|
70
|
+
#### FederationSuccess
|
|
71
71
|
|
|
72
|
-
If federation was successful, the return type is `
|
|
72
|
+
If federation was successful, the return type is `FederationSuccess`.
|
|
73
73
|
|
|
74
|
-
| property
|
|
75
|
-
|
|
|
76
|
-
|
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
74
|
+
| property | Description | type |
|
|
75
|
+
| ------------------------------ | --------------------------------------------------------- | ------------------------------------ |
|
|
76
|
+
| directiveDefinitionByName | map of directive definitions by name | Map<string, DirectiveDefinitionNode> |
|
|
77
|
+
| fieldConfigurations | array of field configurations for the router | Array<FieldConfiguration> |
|
|
78
|
+
| federatedGraphAST | an AST object representation of the federated graph SDL | graphql.DocumentNode |
|
|
79
|
+
| federatedGraphClientSchema | a schema object with client-facing types only | graphql.GraphQLSchema |
|
|
80
|
+
| federatedGraphSchema | a schema object representation of the federated graph SDL | graphql.GraphQLSchema |
|
|
81
|
+
| parentDefinitionDataByTypeName | map of parent type definition data by type name | Map<string, ParentDefinitionData> |
|
|
82
|
+
| subgraphConfigBySubgraphName | map of normalized subgraph config by subgraph name | Map<string, SubgraphConfig> |
|
|
83
|
+
| shouldIncludeClientSchema | whether the client schema should be included (optional) | boolean \| undefined |
|
|
84
|
+
| success | assertion that composition was successful | true |
|
|
85
|
+
| warnings | array of composition warnings (if any) | Array<Warning> |
|
|
80
86
|
|
|
81
|
-
####
|
|
87
|
+
#### FederationFailure
|
|
82
88
|
|
|
83
|
-
If federation was unsuccessful, the return type is `
|
|
89
|
+
If federation was unsuccessful, the return type is `FederationFailure`.
|
|
84
90
|
|
|
85
91
|
| property | Description | type |
|
|
86
92
|
| -------- | ------------------------------------------- | -------------- |
|
|
@@ -96,10 +102,10 @@ In these cases, the errors array will be defined and populated.
|
|
|
96
102
|
An example of a simple debugging framework might be:
|
|
97
103
|
|
|
98
104
|
```typescript
|
|
99
|
-
import { federateSubgraphs, FederationResult, Subgraph } from '@wundergraph
|
|
105
|
+
import { federateSubgraphs, FederationResult, Subgraph } from '@wundergraph/composition';
|
|
100
106
|
import { print, printSchema } from 'graphql';
|
|
101
107
|
|
|
102
|
-
const result: FederationResult = federateSubgraphs([subgraphA, subgraphB]);
|
|
108
|
+
const result: FederationResult = federateSubgraphs({ subgraphs: [subgraphA, subgraphB] });
|
|
103
109
|
|
|
104
110
|
if (result.success) {
|
|
105
111
|
// Both options to print the federated graph as a string are included for documentational purposes only
|
|
@@ -126,7 +132,7 @@ Errors can happen in three main stages:
|
|
|
126
132
|
(if this stage fails, federation will not be attempted)
|
|
127
133
|
3. During the federation process itself.
|
|
128
134
|
|
|
129
|
-
All errors will be appended to the `
|
|
135
|
+
All errors will be appended to the `FederationFailure.errors` array.
|
|
130
136
|
|
|
131
137
|
## Subgraph object
|
|
132
138
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wundergraph/composition",
|
|
3
|
-
"version": "0.54.
|
|
3
|
+
"version": "0.54.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "WunderGraph Maintainers",
|
|
6
6
|
"email": "info@wundergraph.com"
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"typescript": "5.5.2",
|
|
46
46
|
"vitest": "^3.2.4"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "0e5fa811a1910aff80ff66b5746a69655b459708"
|
|
49
49
|
}
|