@graphql-codegen/plugin-helpers 4.2.1-alpha-20230522172441-e282e8469 → 4.2.1-alpha-20230522233947-904521c12
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/cjs/federation.js +7 -4
- package/cjs/oldVisit.js +2 -2
- package/esm/federation.js +7 -4
- package/esm/oldVisit.js +2 -2
- package/package.json +2 -2
package/cjs/federation.js
CHANGED
|
@@ -158,7 +158,7 @@ class ApolloFederation {
|
|
|
158
158
|
}
|
|
159
159
|
hasProvides(objectType, node) {
|
|
160
160
|
const fields = this.providesMap[(0, graphql_1.isObjectType)(objectType) ? objectType.name : objectType.name.value];
|
|
161
|
-
if (fields
|
|
161
|
+
if (fields === null || fields === void 0 ? void 0 : fields.length) {
|
|
162
162
|
return fields.includes(node.name.value);
|
|
163
163
|
}
|
|
164
164
|
return false;
|
|
@@ -190,6 +190,7 @@ class ApolloFederation {
|
|
|
190
190
|
});
|
|
191
191
|
}
|
|
192
192
|
createMapOfProvides() {
|
|
193
|
+
var _a;
|
|
193
194
|
const providesMap = {};
|
|
194
195
|
for (const typename of Object.keys(this.schema.getTypeMap())) {
|
|
195
196
|
const objectType = this.schema.getType(typename);
|
|
@@ -199,7 +200,7 @@ class ApolloFederation {
|
|
|
199
200
|
.map(this.extractFieldSet)
|
|
200
201
|
.reduce((prev, curr) => [...prev, ...Object.keys(curr)], []);
|
|
201
202
|
const ofType = (0, utils_js_1.getBaseType)(field.type);
|
|
202
|
-
providesMap[ofType.name]
|
|
203
|
+
providesMap[_a = ofType.name] || (providesMap[_a] = []);
|
|
203
204
|
providesMap[ofType.name].push(...provides);
|
|
204
205
|
}
|
|
205
206
|
}
|
|
@@ -226,6 +227,7 @@ function isFederationObjectType(node, schema) {
|
|
|
226
227
|
* @param node ObjectType or Field
|
|
227
228
|
*/
|
|
228
229
|
function getDirectivesByName(name, node) {
|
|
230
|
+
var _a;
|
|
229
231
|
let astNode;
|
|
230
232
|
if ((0, graphql_1.isObjectType)(node)) {
|
|
231
233
|
astNode = node.astNode;
|
|
@@ -233,7 +235,7 @@ function getDirectivesByName(name, node) {
|
|
|
233
235
|
else {
|
|
234
236
|
astNode = node;
|
|
235
237
|
}
|
|
236
|
-
return astNode
|
|
238
|
+
return ((_a = astNode === null || astNode === void 0 ? void 0 : astNode.directives) === null || _a === void 0 ? void 0 : _a.filter(d => d.name.value === name)) || [];
|
|
237
239
|
}
|
|
238
240
|
/**
|
|
239
241
|
* Checks if the Object Type extends a federated type from a remote schema.
|
|
@@ -241,6 +243,7 @@ function getDirectivesByName(name, node) {
|
|
|
241
243
|
* @param node Type
|
|
242
244
|
*/
|
|
243
245
|
function isTypeExtension(node, schema) {
|
|
246
|
+
var _a;
|
|
244
247
|
const definition = (0, graphql_1.isObjectType)(node) ? node.astNode || (0, utils_1.astFromObjectType)(node, schema) : node;
|
|
245
|
-
return definition.fields
|
|
248
|
+
return (_a = definition.fields) === null || _a === void 0 ? void 0 : _a.some(field => getDirectivesByName('external', field).length);
|
|
246
249
|
}
|
package/cjs/oldVisit.js
CHANGED
|
@@ -5,13 +5,13 @@ const graphql_1 = require("graphql");
|
|
|
5
5
|
function oldVisit(root, { enter: enterVisitors, leave: leaveVisitors, ...newVisitor }) {
|
|
6
6
|
if (typeof enterVisitors === 'object') {
|
|
7
7
|
for (const key in enterVisitors) {
|
|
8
|
-
newVisitor[key]
|
|
8
|
+
newVisitor[key] || (newVisitor[key] = {});
|
|
9
9
|
newVisitor[key].enter = enterVisitors[key];
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
if (typeof leaveVisitors === 'object') {
|
|
13
13
|
for (const key in leaveVisitors) {
|
|
14
|
-
newVisitor[key]
|
|
14
|
+
newVisitor[key] || (newVisitor[key] = {});
|
|
15
15
|
newVisitor[key].leave = leaveVisitors[key];
|
|
16
16
|
}
|
|
17
17
|
}
|
package/esm/federation.js
CHANGED
|
@@ -152,7 +152,7 @@ export class ApolloFederation {
|
|
|
152
152
|
}
|
|
153
153
|
hasProvides(objectType, node) {
|
|
154
154
|
const fields = this.providesMap[isObjectType(objectType) ? objectType.name : objectType.name.value];
|
|
155
|
-
if (fields
|
|
155
|
+
if (fields === null || fields === void 0 ? void 0 : fields.length) {
|
|
156
156
|
return fields.includes(node.name.value);
|
|
157
157
|
}
|
|
158
158
|
return false;
|
|
@@ -184,6 +184,7 @@ export class ApolloFederation {
|
|
|
184
184
|
});
|
|
185
185
|
}
|
|
186
186
|
createMapOfProvides() {
|
|
187
|
+
var _a;
|
|
187
188
|
const providesMap = {};
|
|
188
189
|
for (const typename of Object.keys(this.schema.getTypeMap())) {
|
|
189
190
|
const objectType = this.schema.getType(typename);
|
|
@@ -193,7 +194,7 @@ export class ApolloFederation {
|
|
|
193
194
|
.map(this.extractFieldSet)
|
|
194
195
|
.reduce((prev, curr) => [...prev, ...Object.keys(curr)], []);
|
|
195
196
|
const ofType = getBaseType(field.type);
|
|
196
|
-
providesMap[ofType.name]
|
|
197
|
+
providesMap[_a = ofType.name] || (providesMap[_a] = []);
|
|
197
198
|
providesMap[ofType.name].push(...provides);
|
|
198
199
|
}
|
|
199
200
|
}
|
|
@@ -219,6 +220,7 @@ function isFederationObjectType(node, schema) {
|
|
|
219
220
|
* @param node ObjectType or Field
|
|
220
221
|
*/
|
|
221
222
|
function getDirectivesByName(name, node) {
|
|
223
|
+
var _a;
|
|
222
224
|
let astNode;
|
|
223
225
|
if (isObjectType(node)) {
|
|
224
226
|
astNode = node.astNode;
|
|
@@ -226,7 +228,7 @@ function getDirectivesByName(name, node) {
|
|
|
226
228
|
else {
|
|
227
229
|
astNode = node;
|
|
228
230
|
}
|
|
229
|
-
return astNode
|
|
231
|
+
return ((_a = astNode === null || astNode === void 0 ? void 0 : astNode.directives) === null || _a === void 0 ? void 0 : _a.filter(d => d.name.value === name)) || [];
|
|
230
232
|
}
|
|
231
233
|
/**
|
|
232
234
|
* Checks if the Object Type extends a federated type from a remote schema.
|
|
@@ -234,6 +236,7 @@ function getDirectivesByName(name, node) {
|
|
|
234
236
|
* @param node Type
|
|
235
237
|
*/
|
|
236
238
|
function isTypeExtension(node, schema) {
|
|
239
|
+
var _a;
|
|
237
240
|
const definition = isObjectType(node) ? node.astNode || astFromObjectType(node, schema) : node;
|
|
238
|
-
return definition.fields
|
|
241
|
+
return (_a = definition.fields) === null || _a === void 0 ? void 0 : _a.some(field => getDirectivesByName('external', field).length);
|
|
239
242
|
}
|
package/esm/oldVisit.js
CHANGED
|
@@ -2,13 +2,13 @@ import { visit } from 'graphql';
|
|
|
2
2
|
export function oldVisit(root, { enter: enterVisitors, leave: leaveVisitors, ...newVisitor }) {
|
|
3
3
|
if (typeof enterVisitors === 'object') {
|
|
4
4
|
for (const key in enterVisitors) {
|
|
5
|
-
newVisitor[key]
|
|
5
|
+
newVisitor[key] || (newVisitor[key] = {});
|
|
6
6
|
newVisitor[key].enter = enterVisitors[key];
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
if (typeof leaveVisitors === 'object') {
|
|
10
10
|
for (const key in leaveVisitors) {
|
|
11
|
-
newVisitor[key]
|
|
11
|
+
newVisitor[key] || (newVisitor[key] = {});
|
|
12
12
|
newVisitor[key].leave = leaveVisitors[key];
|
|
13
13
|
}
|
|
14
14
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/plugin-helpers",
|
|
3
|
-
"version": "4.2.1-alpha-
|
|
3
|
+
"version": "4.2.1-alpha-20230522233947-904521c12",
|
|
4
4
|
"description": "GraphQL Code Generator common utils and types",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@graphql-tools/utils": "^
|
|
9
|
+
"@graphql-tools/utils": "^9.0.0",
|
|
10
10
|
"change-case-all": "1.0.15",
|
|
11
11
|
"common-tags": "1.8.2",
|
|
12
12
|
"import-from": "4.0.0",
|