@theguild/federation-composition 0.12.0 → 0.12.1-alpha-20240715091441-86eb8b7
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.
|
@@ -6,6 +6,7 @@ const format_js_1 = require("../../utils/format.js");
|
|
|
6
6
|
const state_js_1 = require("../../utils/state.js");
|
|
7
7
|
const state_js_2 = require("../state.js");
|
|
8
8
|
const specifiedScalars = new Set(graphql_1.specifiedScalarTypes.map(t => t.name));
|
|
9
|
+
const SKIP = Symbol('skip');
|
|
9
10
|
function validateSubgraphState(state, context) {
|
|
10
11
|
const errors = [];
|
|
11
12
|
function reportError(message) {
|
|
@@ -71,7 +72,11 @@ function validateDirectives(state, reportError, context) {
|
|
|
71
72
|
if (context.isLinkSpecType(argInputTypeName)) {
|
|
72
73
|
continue;
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
const isInput = isInputType(state, argInputTypeName);
|
|
76
|
+
if (isInput === SKIP) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (!isInput) {
|
|
75
80
|
reportError(`The type of @${directive.name}(${arg.name}:) must be Input Type ` +
|
|
76
81
|
`but got: ${arg.type}.`);
|
|
77
82
|
}
|
|
@@ -159,7 +164,11 @@ function validateFields(state, reportError, type) {
|
|
|
159
164
|
if (!fieldTypeExists) {
|
|
160
165
|
continue;
|
|
161
166
|
}
|
|
162
|
-
|
|
167
|
+
const isOutput = isOutputType(state, fieldTypeName);
|
|
168
|
+
if (isOutput === SKIP) {
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
if (!isOutput) {
|
|
163
172
|
reportError(`The type of "${type.name}.${field.name}" must be Output Type but got: "${field.type}".`);
|
|
164
173
|
}
|
|
165
174
|
for (const arg of field.args.values()) {
|
|
@@ -170,7 +179,11 @@ function validateFields(state, reportError, type) {
|
|
|
170
179
|
if (!argTypeExists) {
|
|
171
180
|
continue;
|
|
172
181
|
}
|
|
173
|
-
|
|
182
|
+
const isInput = isInputType(state, argTypeName);
|
|
183
|
+
if (isInput === SKIP) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
if (!isInput) {
|
|
174
187
|
const isList = arg.type.endsWith(']');
|
|
175
188
|
const isNonNull = arg.type.endsWith('!');
|
|
176
189
|
const extra = isList ? ', a ListType' : isNonNull ? ', a NonNullType' : '';
|
|
@@ -284,7 +297,11 @@ function validateInputFields(state, reportError, inputObj) {
|
|
|
284
297
|
if (!fieldTypeExists) {
|
|
285
298
|
continue;
|
|
286
299
|
}
|
|
287
|
-
|
|
300
|
+
const isInput = isInputType(state, fieldTypeName);
|
|
301
|
+
if (isInput === SKIP) {
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (!isInput) {
|
|
288
305
|
const isList = field.type.endsWith(']');
|
|
289
306
|
const isNonNull = field.type.endsWith('!');
|
|
290
307
|
const extra = isList ? ', a ListType' : isNonNull ? ', a NonNullType' : '';
|
|
@@ -456,7 +473,7 @@ function isOutputType(state, typeName) {
|
|
|
456
473
|
if (specifiedScalars.has(typeName)) {
|
|
457
474
|
return true;
|
|
458
475
|
}
|
|
459
|
-
|
|
476
|
+
return SKIP;
|
|
460
477
|
}
|
|
461
478
|
return !isInputObjectType(type);
|
|
462
479
|
}
|
|
@@ -466,7 +483,7 @@ function isInputType(state, typeName) {
|
|
|
466
483
|
if (specifiedScalars.has(typeName)) {
|
|
467
484
|
return true;
|
|
468
485
|
}
|
|
469
|
-
|
|
486
|
+
return SKIP;
|
|
470
487
|
}
|
|
471
488
|
return isScalarType(type) || isEnumType(type) || isInputObjectType(type);
|
|
472
489
|
}
|
|
@@ -3,6 +3,7 @@ import { andList } from '../../utils/format.js';
|
|
|
3
3
|
import { isList, isNonNull, stripList, stripNonNull, stripTypeModifiers, } from '../../utils/state.js';
|
|
4
4
|
import { TypeKind, } from '../state.js';
|
|
5
5
|
const specifiedScalars = new Set(specifiedScalarTypes.map(t => t.name));
|
|
6
|
+
const SKIP = Symbol('skip');
|
|
6
7
|
export function validateSubgraphState(state, context) {
|
|
7
8
|
const errors = [];
|
|
8
9
|
function reportError(message) {
|
|
@@ -67,7 +68,11 @@ function validateDirectives(state, reportError, context) {
|
|
|
67
68
|
if (context.isLinkSpecType(argInputTypeName)) {
|
|
68
69
|
continue;
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
+
const isInput = isInputType(state, argInputTypeName);
|
|
72
|
+
if (isInput === SKIP) {
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (!isInput) {
|
|
71
76
|
reportError(`The type of @${directive.name}(${arg.name}:) must be Input Type ` +
|
|
72
77
|
`but got: ${arg.type}.`);
|
|
73
78
|
}
|
|
@@ -155,7 +160,11 @@ function validateFields(state, reportError, type) {
|
|
|
155
160
|
if (!fieldTypeExists) {
|
|
156
161
|
continue;
|
|
157
162
|
}
|
|
158
|
-
|
|
163
|
+
const isOutput = isOutputType(state, fieldTypeName);
|
|
164
|
+
if (isOutput === SKIP) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (!isOutput) {
|
|
159
168
|
reportError(`The type of "${type.name}.${field.name}" must be Output Type but got: "${field.type}".`);
|
|
160
169
|
}
|
|
161
170
|
for (const arg of field.args.values()) {
|
|
@@ -166,7 +175,11 @@ function validateFields(state, reportError, type) {
|
|
|
166
175
|
if (!argTypeExists) {
|
|
167
176
|
continue;
|
|
168
177
|
}
|
|
169
|
-
|
|
178
|
+
const isInput = isInputType(state, argTypeName);
|
|
179
|
+
if (isInput === SKIP) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
if (!isInput) {
|
|
170
183
|
const isList = arg.type.endsWith(']');
|
|
171
184
|
const isNonNull = arg.type.endsWith('!');
|
|
172
185
|
const extra = isList ? ', a ListType' : isNonNull ? ', a NonNullType' : '';
|
|
@@ -280,7 +293,11 @@ function validateInputFields(state, reportError, inputObj) {
|
|
|
280
293
|
if (!fieldTypeExists) {
|
|
281
294
|
continue;
|
|
282
295
|
}
|
|
283
|
-
|
|
296
|
+
const isInput = isInputType(state, fieldTypeName);
|
|
297
|
+
if (isInput === SKIP) {
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
if (!isInput) {
|
|
284
301
|
const isList = field.type.endsWith(']');
|
|
285
302
|
const isNonNull = field.type.endsWith('!');
|
|
286
303
|
const extra = isList ? ', a ListType' : isNonNull ? ', a NonNullType' : '';
|
|
@@ -451,7 +468,7 @@ function isOutputType(state, typeName) {
|
|
|
451
468
|
if (specifiedScalars.has(typeName)) {
|
|
452
469
|
return true;
|
|
453
470
|
}
|
|
454
|
-
|
|
471
|
+
return SKIP;
|
|
455
472
|
}
|
|
456
473
|
return !isInputObjectType(type);
|
|
457
474
|
}
|
|
@@ -461,7 +478,7 @@ export function isInputType(state, typeName) {
|
|
|
461
478
|
if (specifiedScalars.has(typeName)) {
|
|
462
479
|
return true;
|
|
463
480
|
}
|
|
464
|
-
|
|
481
|
+
return SKIP;
|
|
465
482
|
}
|
|
466
483
|
return isScalarType(type) || isEnumType(type) || isInputObjectType(type);
|
|
467
484
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { GraphQLError } from 'graphql';
|
|
2
2
|
import { Directive, EnumType, InputObjectType, InterfaceType, ObjectType, ScalarType, SubgraphState, SubgraphType, UnionType } from '../state.cjs';
|
|
3
3
|
import { SubgraphValidationContext } from './validation-context.cjs';
|
|
4
|
+
declare const SKIP: unique symbol;
|
|
4
5
|
export declare function validateSubgraphState(state: SubgraphState, context: SubgraphValidationContext): GraphQLError[];
|
|
5
6
|
export declare function isTypeSubTypeOf(state: SubgraphState, implementationsMap: Map<string, Set<string>>, maybeSubTypeName: string, superTypeName: string): boolean;
|
|
6
|
-
export declare function isInputType(state: SubgraphState, typeName: string): boolean;
|
|
7
|
+
export declare function isInputType(state: SubgraphState, typeName: string): boolean | typeof SKIP;
|
|
7
8
|
export declare function typeExists(state: SubgraphState, typeName: string): boolean;
|
|
8
9
|
export declare function isInputObjectType(type: SubgraphType): type is InputObjectType;
|
|
9
10
|
export declare function isScalarType(type: SubgraphType): type is ScalarType;
|
|
@@ -12,4 +13,5 @@ export declare function isObjectType(type: SubgraphType): type is ObjectType;
|
|
|
12
13
|
export declare function isInterfaceType(type: SubgraphType): type is InterfaceType;
|
|
13
14
|
export declare function isUnionType(type: SubgraphType): type is UnionType;
|
|
14
15
|
export declare function isDirective(type: SubgraphType): type is Directive;
|
|
16
|
+
export {};
|
|
15
17
|
//# sourceMappingURL=validate-state.d.ts.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { GraphQLError } from 'graphql';
|
|
2
2
|
import { Directive, EnumType, InputObjectType, InterfaceType, ObjectType, ScalarType, SubgraphState, SubgraphType, UnionType } from '../state.js';
|
|
3
3
|
import { SubgraphValidationContext } from './validation-context.js';
|
|
4
|
+
declare const SKIP: unique symbol;
|
|
4
5
|
export declare function validateSubgraphState(state: SubgraphState, context: SubgraphValidationContext): GraphQLError[];
|
|
5
6
|
export declare function isTypeSubTypeOf(state: SubgraphState, implementationsMap: Map<string, Set<string>>, maybeSubTypeName: string, superTypeName: string): boolean;
|
|
6
|
-
export declare function isInputType(state: SubgraphState, typeName: string): boolean;
|
|
7
|
+
export declare function isInputType(state: SubgraphState, typeName: string): boolean | typeof SKIP;
|
|
7
8
|
export declare function typeExists(state: SubgraphState, typeName: string): boolean;
|
|
8
9
|
export declare function isInputObjectType(type: SubgraphType): type is InputObjectType;
|
|
9
10
|
export declare function isScalarType(type: SubgraphType): type is ScalarType;
|
|
@@ -12,4 +13,5 @@ export declare function isObjectType(type: SubgraphType): type is ObjectType;
|
|
|
12
13
|
export declare function isInterfaceType(type: SubgraphType): type is InterfaceType;
|
|
13
14
|
export declare function isUnionType(type: SubgraphType): type is UnionType;
|
|
14
15
|
export declare function isDirective(type: SubgraphType): type is Directive;
|
|
16
|
+
export {};
|
|
15
17
|
//# sourceMappingURL=validate-state.d.ts.map
|