@graphql-codegen/plugin-helpers 6.2.0 → 6.2.1-alpha-20260402132841-648e5bf0161e5499140abb2fa0350274a3ba8fb3
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 +13 -5
- package/cjs/utils.js +5 -1
- package/esm/federation.js +13 -5
- package/esm/utils.js +6 -2
- package/package.json +1 -1
- package/typings/federation.d.cts +1 -1
- package/typings/federation.d.ts +1 -1
- package/typings/types.d.cts +1 -1
- package/typings/types.d.ts +1 -1
package/cjs/federation.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ApolloFederation = exports.federationSpec = void 0;
|
|
4
4
|
exports.addFederationReferencesToSchema = addFederationReferencesToSchema;
|
|
5
5
|
exports.removeFederation = removeFederation;
|
|
6
|
-
const utils_1 = require("@graphql-tools/utils");
|
|
7
6
|
const graphql_1 = require("graphql");
|
|
7
|
+
const utils_1 = require("@graphql-tools/utils");
|
|
8
8
|
const index_js_1 = require("./index.js");
|
|
9
9
|
const utils_js_1 = require("./utils.js");
|
|
10
10
|
/**
|
|
@@ -43,7 +43,10 @@ function addFederationReferencesToSchema(schema) {
|
|
|
43
43
|
// @key() @key() - "primary keys" in Federation
|
|
44
44
|
// A reference may receive one primary key combination at a time, so they will be combined with `|`
|
|
45
45
|
const primaryKeys = resolvableKeyDirectives.map(extractReferenceSelectionSet);
|
|
46
|
-
referenceSelectionSets.push({
|
|
46
|
+
referenceSelectionSets.push({
|
|
47
|
+
directive: '@key',
|
|
48
|
+
selectionSets: [...primaryKeys],
|
|
49
|
+
});
|
|
47
50
|
const requiresPossibleTypes = [];
|
|
48
51
|
for (const fieldNode of Object.values(fields)) {
|
|
49
52
|
// Look for @requires and see what the service needs and gets
|
|
@@ -53,7 +56,10 @@ function addFederationReferencesToSchema(schema) {
|
|
|
53
56
|
requiresPossibleTypes.push(requires);
|
|
54
57
|
}
|
|
55
58
|
}
|
|
56
|
-
referenceSelectionSets.push({
|
|
59
|
+
referenceSelectionSets.push({
|
|
60
|
+
directive: '@requires',
|
|
61
|
+
selectionSets: requiresPossibleTypes,
|
|
62
|
+
});
|
|
57
63
|
return referenceSelectionSets;
|
|
58
64
|
};
|
|
59
65
|
/**
|
|
@@ -254,7 +260,7 @@ class ApolloFederation {
|
|
|
254
260
|
*/
|
|
255
261
|
fieldsToGenerate;
|
|
256
262
|
meta = {};
|
|
257
|
-
constructor({ enabled, schema, meta }) {
|
|
263
|
+
constructor({ enabled, schema, meta, }) {
|
|
258
264
|
this.enabled = enabled;
|
|
259
265
|
this.schema = schema;
|
|
260
266
|
this.providesMap = this.createMapOfProvides();
|
|
@@ -395,7 +401,9 @@ function checkTypeFederationDetails(node, schema) {
|
|
|
395
401
|
}
|
|
396
402
|
const resolvableKeyDirectives = keyDirectives.filter(d => {
|
|
397
403
|
for (const arg of d.arguments) {
|
|
398
|
-
if (arg.name.value === 'resolvable' &&
|
|
404
|
+
if (arg.name.value === 'resolvable' &&
|
|
405
|
+
arg.value.kind === 'BooleanValue' &&
|
|
406
|
+
arg.value.value === false) {
|
|
399
407
|
return false;
|
|
400
408
|
}
|
|
401
409
|
}
|
package/cjs/utils.js
CHANGED
|
@@ -6,7 +6,11 @@ exports.getBaseType = getBaseType;
|
|
|
6
6
|
exports.removeNonNullWrapper = removeNonNullWrapper;
|
|
7
7
|
const graphql_1 = require("graphql");
|
|
8
8
|
function mergeOutputs(content) {
|
|
9
|
-
const result = {
|
|
9
|
+
const result = {
|
|
10
|
+
content: '',
|
|
11
|
+
prepend: [],
|
|
12
|
+
append: [],
|
|
13
|
+
};
|
|
10
14
|
if (Array.isArray(content)) {
|
|
11
15
|
for (const item of content) {
|
|
12
16
|
if (typeof item === 'string') {
|
package/esm/federation.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { astFromInterfaceType, astFromObjectType, getRootTypeNames, MapperKind, mapSchema } from '@graphql-tools/utils';
|
|
2
1
|
import { GraphQLInterfaceType, GraphQLObjectType, isObjectType, parse, } from 'graphql';
|
|
2
|
+
import { astFromInterfaceType, astFromObjectType, getRootTypeNames, MapperKind, mapSchema, } from '@graphql-tools/utils';
|
|
3
3
|
import { oldVisit } from './index.js';
|
|
4
4
|
import { getBaseType } from './utils.js';
|
|
5
5
|
/**
|
|
@@ -38,7 +38,10 @@ export function addFederationReferencesToSchema(schema) {
|
|
|
38
38
|
// @key() @key() - "primary keys" in Federation
|
|
39
39
|
// A reference may receive one primary key combination at a time, so they will be combined with `|`
|
|
40
40
|
const primaryKeys = resolvableKeyDirectives.map(extractReferenceSelectionSet);
|
|
41
|
-
referenceSelectionSets.push({
|
|
41
|
+
referenceSelectionSets.push({
|
|
42
|
+
directive: '@key',
|
|
43
|
+
selectionSets: [...primaryKeys],
|
|
44
|
+
});
|
|
42
45
|
const requiresPossibleTypes = [];
|
|
43
46
|
for (const fieldNode of Object.values(fields)) {
|
|
44
47
|
// Look for @requires and see what the service needs and gets
|
|
@@ -48,7 +51,10 @@ export function addFederationReferencesToSchema(schema) {
|
|
|
48
51
|
requiresPossibleTypes.push(requires);
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
|
-
referenceSelectionSets.push({
|
|
54
|
+
referenceSelectionSets.push({
|
|
55
|
+
directive: '@requires',
|
|
56
|
+
selectionSets: requiresPossibleTypes,
|
|
57
|
+
});
|
|
52
58
|
return referenceSelectionSets;
|
|
53
59
|
};
|
|
54
60
|
/**
|
|
@@ -249,7 +255,7 @@ export class ApolloFederation {
|
|
|
249
255
|
*/
|
|
250
256
|
fieldsToGenerate;
|
|
251
257
|
meta = {};
|
|
252
|
-
constructor({ enabled, schema, meta }) {
|
|
258
|
+
constructor({ enabled, schema, meta, }) {
|
|
253
259
|
this.enabled = enabled;
|
|
254
260
|
this.schema = schema;
|
|
255
261
|
this.providesMap = this.createMapOfProvides();
|
|
@@ -389,7 +395,9 @@ function checkTypeFederationDetails(node, schema) {
|
|
|
389
395
|
}
|
|
390
396
|
const resolvableKeyDirectives = keyDirectives.filter(d => {
|
|
391
397
|
for (const arg of d.arguments) {
|
|
392
|
-
if (arg.name.value === 'resolvable' &&
|
|
398
|
+
if (arg.name.value === 'resolvable' &&
|
|
399
|
+
arg.value.kind === 'BooleanValue' &&
|
|
400
|
+
arg.value.value === false) {
|
|
393
401
|
return false;
|
|
394
402
|
}
|
|
395
403
|
}
|
package/esm/utils.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { isListType, isNonNullType } from 'graphql';
|
|
1
|
+
import { isListType, isNonNullType, } from 'graphql';
|
|
2
2
|
export function mergeOutputs(content) {
|
|
3
|
-
const result = {
|
|
3
|
+
const result = {
|
|
4
|
+
content: '',
|
|
5
|
+
prepend: [],
|
|
6
|
+
append: [],
|
|
7
|
+
};
|
|
4
8
|
if (Array.isArray(content)) {
|
|
5
9
|
for (const item of content) {
|
|
6
10
|
if (typeof item === 'string') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/plugin-helpers",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.1-alpha-20260402132841-648e5bf0161e5499140abb2fa0350274a3ba8fb3",
|
|
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"
|
package/typings/federation.d.cts
CHANGED
|
@@ -52,7 +52,7 @@ export declare class ApolloFederation {
|
|
|
52
52
|
*/
|
|
53
53
|
private fieldsToGenerate;
|
|
54
54
|
protected meta: FederationMeta;
|
|
55
|
-
constructor({ enabled, schema, meta }: {
|
|
55
|
+
constructor({ enabled, schema, meta, }: {
|
|
56
56
|
enabled: boolean;
|
|
57
57
|
schema: GraphQLSchema;
|
|
58
58
|
meta: FederationMeta;
|
package/typings/federation.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare class ApolloFederation {
|
|
|
52
52
|
*/
|
|
53
53
|
private fieldsToGenerate;
|
|
54
54
|
protected meta: FederationMeta;
|
|
55
|
-
constructor({ enabled, schema, meta }: {
|
|
55
|
+
constructor({ enabled, schema, meta, }: {
|
|
56
56
|
enabled: boolean;
|
|
57
57
|
schema: GraphQLSchema;
|
|
58
58
|
meta: FederationMeta;
|
package/typings/types.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { DocumentNode, GraphQLSchema } from 'graphql';
|
|
1
2
|
import type { ApolloEngineOptions } from '@graphql-tools/apollo-engine-loader';
|
|
2
3
|
import { Source } from '@graphql-tools/utils';
|
|
3
|
-
import { DocumentNode, GraphQLSchema } from 'graphql';
|
|
4
4
|
import type { Profiler } from './profiler.cjs';
|
|
5
5
|
export declare namespace Types {
|
|
6
6
|
interface GenerateOptions {
|
package/typings/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { DocumentNode, GraphQLSchema } from 'graphql';
|
|
1
2
|
import type { ApolloEngineOptions } from '@graphql-tools/apollo-engine-loader';
|
|
2
3
|
import { Source } from '@graphql-tools/utils';
|
|
3
|
-
import { DocumentNode, GraphQLSchema } from 'graphql';
|
|
4
4
|
import type { Profiler } from './profiler.js';
|
|
5
5
|
export declare namespace Types {
|
|
6
6
|
interface GenerateOptions {
|