@wundergraph/composition 0.36.0 → 0.37.0
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/dist/ast/utils.d.ts +0 -2
- package/dist/ast/utils.js +0 -31
- package/dist/ast/utils.js.map +1 -1
- package/dist/errors/errors.d.ts +3 -3
- package/dist/errors/errors.js +11 -7
- package/dist/errors/errors.js.map +1 -1
- package/dist/federation/federation.d.ts +6 -0
- package/dist/federation/federation.js +30 -0
- package/dist/federation/federation.js.map +1 -0
- package/dist/federation/types.d.ts +44 -0
- package/dist/federation/types.js +3 -0
- package/dist/federation/types.js.map +1 -0
- package/dist/index.d.ts +21 -13
- package/dist/index.js +22 -13
- package/dist/index.js.map +1 -1
- package/dist/normalization/normalization.d.ts +6 -0
- package/dist/normalization/normalization.js +21 -0
- package/dist/normalization/normalization.js.map +1 -0
- package/dist/normalization/types.d.ts +48 -0
- package/dist/normalization/types.js +3 -0
- package/dist/normalization/types.js.map +1 -0
- package/dist/resolvability-graph/graph.d.ts +2 -2
- package/dist/resolvability-graph/graph.js +21 -21
- package/dist/resolvability-graph/graph.js.map +1 -1
- package/dist/resolvability-graph/utils.js +2 -2
- package/dist/resolvability-graph/utils.js.map +1 -1
- package/dist/router-compatibility-version/router-compatibility-version.d.ts +4 -0
- package/dist/router-compatibility-version/router-compatibility-version.js +7 -0
- package/dist/router-compatibility-version/router-compatibility-version.js.map +1 -0
- package/dist/schema-building/ast.js.map +1 -1
- package/dist/schema-building/{type-definition-data.d.ts → types.d.ts} +34 -3
- package/dist/schema-building/{type-definition-data.js → types.js} +1 -1
- package/dist/schema-building/types.js.map +1 -0
- package/dist/schema-building/utils.d.ts +2 -7
- package/dist/schema-building/utils.js +5 -6
- package/dist/schema-building/utils.js.map +1 -1
- package/dist/subgraph/{subgraph.d.ts → types.d.ts} +5 -8
- package/dist/subgraph/types.js +3 -0
- package/dist/subgraph/types.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/composition-version.js +1 -1
- package/dist/utils/integer-constants.d.ts +0 -1
- package/dist/utils/integer-constants.js +1 -2
- package/dist/utils/integer-constants.js.map +1 -1
- package/dist/utils/string-constants.d.ts +2 -7
- package/dist/utils/string-constants.js +3 -30
- package/dist/utils/string-constants.js.map +1 -1
- package/dist/utils/types.d.ts +1 -0
- package/dist/utils/types.js +3 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/utils.d.ts +10 -74
- package/dist/utils/utils.js +33 -386
- package/dist/utils/utils.js.map +1 -1
- package/dist/{federation → v1/federation}/federation-factory.d.ts +18 -17
- package/dist/{federation → v1/federation}/federation-factory.js +202 -199
- package/dist/v1/federation/federation-factory.js.map +1 -0
- package/dist/{federation → v1/federation}/utils.d.ts +11 -35
- package/dist/{federation → v1/federation}/utils.js +8 -8
- package/dist/v1/federation/utils.js.map +1 -0
- package/dist/{federation → v1/federation}/walkers.d.ts +1 -1
- package/dist/{federation → v1/federation}/walkers.js +10 -10
- package/dist/v1/federation/walkers.js.map +1 -0
- package/dist/{normalization → v1/normalization}/directive-definition-data.d.ts +1 -1
- package/dist/{normalization → v1/normalization}/directive-definition-data.js +2 -2
- package/dist/v1/normalization/directive-definition-data.js.map +1 -0
- package/dist/{normalization → v1/normalization}/normalization-factory.d.ts +29 -54
- package/dist/{normalization → v1/normalization}/normalization-factory.js +201 -202
- package/dist/v1/normalization/normalization-factory.js.map +1 -0
- package/dist/{normalization → v1/normalization}/utils.d.ts +2 -2
- package/dist/{normalization → v1/normalization}/utils.js +33 -34
- package/dist/v1/normalization/utils.js.map +1 -0
- package/dist/{normalization → v1/normalization}/walkers.js +37 -35
- package/dist/v1/normalization/walkers.js.map +1 -0
- package/dist/{schema-building → v1/schema-building}/type-merging.d.ts +1 -1
- package/dist/{schema-building → v1/schema-building}/type-merging.js +4 -4
- package/dist/v1/schema-building/type-merging.js.map +1 -0
- package/dist/v1/subgraph/subgraph.d.ts +1 -0
- package/dist/v1/subgraph/subgraph.js.map +1 -0
- package/dist/{utils → v1/utils}/constants.d.ts +1 -2
- package/dist/{utils → v1/utils}/constants.js +7 -8
- package/dist/v1/utils/constants.js.map +1 -0
- package/dist/v1/utils/integer-constants.d.ts +1 -0
- package/dist/v1/utils/integer-constants.js +5 -0
- package/dist/v1/utils/integer-constants.js.map +1 -0
- package/dist/v1/utils/string-constants.d.ts +5 -0
- package/dist/v1/utils/string-constants.js +32 -0
- package/dist/v1/utils/string-constants.js.map +1 -0
- package/dist/v1/utils/utils.d.ts +35 -0
- package/dist/v1/utils/utils.js +330 -0
- package/dist/v1/utils/utils.js.map +1 -0
- package/dist/v1/warnings/warnings.d.ts +9 -0
- package/dist/v1/warnings/warnings.js +104 -0
- package/dist/v1/warnings/warnings.js.map +1 -0
- package/dist/warnings/warnings.d.ts +0 -8
- package/dist/warnings/warnings.js +0 -100
- package/dist/warnings/warnings.js.map +1 -1
- package/package.json +2 -2
- package/dist/federation/federation-factory.js.map +0 -1
- package/dist/federation/utils.js.map +0 -1
- package/dist/federation/walkers.js.map +0 -1
- package/dist/normalization/directive-definition-data.js.map +0 -1
- package/dist/normalization/normalization-factory.js.map +0 -1
- package/dist/normalization/utils.js.map +0 -1
- package/dist/normalization/walkers.js.map +0 -1
- package/dist/schema-building/type-definition-data.js.map +0 -1
- package/dist/schema-building/type-merging.js.map +0 -1
- package/dist/subgraph/subgraph.js.map +0 -1
- package/dist/utils/constants.js.map +0 -1
- /package/dist/{normalization → v1/normalization}/walkers.d.ts +0 -0
- /package/dist/{subgraph → v1/subgraph}/subgraph.js +0 -0
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import { ConstDirectiveNode,
|
|
2
|
-
import {
|
|
3
|
-
import { FieldConfiguration } from '../router-configuration/router-configuration';
|
|
4
|
-
import { FieldData } from '../schema-building/type-definition-data';
|
|
1
|
+
import { ConstDirectiveNode, Kind } from 'graphql/index';
|
|
2
|
+
import { SimpleFieldData } from '../schema-building/types';
|
|
5
3
|
export declare function areSetsEqual<T>(set: Set<T>, other: Set<T>): boolean;
|
|
6
4
|
export declare function getAllMutualEntries<T>(set: Set<T>, other: Set<T>): Set<T>;
|
|
7
5
|
export declare function getOrThrowError<K, V>(map: Map<K, V>, key: K, mapName: string): V;
|
|
8
6
|
export declare function getAllSetDisparities<T>(set: Set<T>, other: Set<T>): T[];
|
|
9
7
|
export declare function getEntriesNotInHashSet<T>(iterable: Iterable<T>, comparison: Set<T> | Map<T, any>): T[];
|
|
10
|
-
export declare function doSetsIntersect<T>(set: Set<T>, other: Set<T>): boolean;
|
|
11
|
-
export declare function subtractSourceSetFromTargetSet<T>(source: Set<T>, target: Set<T>): void;
|
|
12
|
-
export declare function mapToArrayOfValues<K, V>(map: Map<K, V>): V[];
|
|
13
8
|
export declare function numberToOrdinal(num: number): string;
|
|
14
9
|
export declare function addIterableValuesToSet<T>(source: T[] | Iterable<T>, target: Set<T>): void;
|
|
15
|
-
export declare function addSetsAndReturnMutationBoolean<T>(source: Set<T>, target: Set<T>): boolean;
|
|
16
10
|
export declare function kindToTypeString(kind: Kind): string;
|
|
17
|
-
export declare function kindToConvertedTypeString(kind: Kind): string;
|
|
18
11
|
export type InvalidArgumentImplementation = {
|
|
19
12
|
actualType: string;
|
|
20
13
|
argumentName: string;
|
|
@@ -32,6 +25,14 @@ export type ImplementationErrors = {
|
|
|
32
25
|
invalidFieldImplementations: Map<string, InvalidFieldImplementation>;
|
|
33
26
|
unimplementedFields: string[];
|
|
34
27
|
};
|
|
28
|
+
export declare function getValueOrDefault<K, V>(map: Map<K, V>, key: K, constructor: () => V): V;
|
|
29
|
+
export type GraphFieldData = {
|
|
30
|
+
name: string;
|
|
31
|
+
namedTypeName: string;
|
|
32
|
+
isLeaf: boolean;
|
|
33
|
+
subgraphNames: Set<string>;
|
|
34
|
+
};
|
|
35
|
+
export declare function add<T>(set: Set<T>, key: T): boolean;
|
|
35
36
|
export type InvalidRequiredInputValueData = {
|
|
36
37
|
inputValueName: string;
|
|
37
38
|
missingSubgraphs: string[];
|
|
@@ -43,26 +44,6 @@ export type InvalidArgument = {
|
|
|
43
44
|
typeName: string;
|
|
44
45
|
typeString: string;
|
|
45
46
|
};
|
|
46
|
-
export type SimpleFieldData = {
|
|
47
|
-
name: string;
|
|
48
|
-
namedTypeName: string;
|
|
49
|
-
};
|
|
50
|
-
export declare function fieldDatasToSimpleFieldDatas(fieldDatas: IterableIterator<FieldData>): Array<SimpleFieldData>;
|
|
51
|
-
export declare function isNodeLeaf(kind?: Kind): boolean;
|
|
52
|
-
export type GraphFieldData = {
|
|
53
|
-
name: string;
|
|
54
|
-
namedTypeName: string;
|
|
55
|
-
isLeaf: boolean;
|
|
56
|
-
subgraphNames: Set<string>;
|
|
57
|
-
};
|
|
58
|
-
export type EntityInterfaceSubgraphData = {
|
|
59
|
-
fieldDatas: Array<SimpleFieldData>;
|
|
60
|
-
interfaceFieldNames: Set<string>;
|
|
61
|
-
interfaceObjectFieldNames: Set<string>;
|
|
62
|
-
isInterfaceObject: boolean;
|
|
63
|
-
typeName: string;
|
|
64
|
-
concreteTypeNames?: Set<string>;
|
|
65
|
-
};
|
|
66
47
|
export type EntityInterfaceFederationData = {
|
|
67
48
|
fieldDatasBySubgraphName: Map<string, Array<SimpleFieldData>>;
|
|
68
49
|
interfaceFieldNames: Set<string>;
|
|
@@ -71,54 +52,9 @@ export type EntityInterfaceFederationData = {
|
|
|
71
52
|
typeName: string;
|
|
72
53
|
concreteTypeNames?: Set<string>;
|
|
73
54
|
};
|
|
74
|
-
export declare function newEntityInterfaceFederationData(entityInterfaceData: EntityInterfaceSubgraphData, subgraphName: string): EntityInterfaceFederationData;
|
|
75
|
-
export declare function upsertEntityInterfaceFederationData(federationData: EntityInterfaceFederationData, subgraphData: EntityInterfaceSubgraphData, subgraphName: string): boolean;
|
|
76
55
|
export type InvalidEntityInterface = {
|
|
77
56
|
subgraphName: string;
|
|
78
57
|
concreteTypeNames: Set<string>;
|
|
79
58
|
};
|
|
80
|
-
export declare function getValueOrDefault<K, V>(map: Map<K, V>, key: K, constructor: () => V): V;
|
|
81
|
-
export type EntityData = {
|
|
82
|
-
fieldNames: Set<string>;
|
|
83
|
-
keyFieldSets: Set<string>;
|
|
84
|
-
subgraphNames: Set<string>;
|
|
85
|
-
typeName: string;
|
|
86
|
-
};
|
|
87
|
-
export type EntityDataParams = {
|
|
88
|
-
typeName: string;
|
|
89
|
-
fieldNames?: Iterable<string>;
|
|
90
|
-
keyFieldSets?: Iterable<string>;
|
|
91
|
-
subgraphNames?: Iterable<string>;
|
|
92
|
-
};
|
|
93
|
-
export declare function newEntityData(params: EntityDataParams): EntityData;
|
|
94
|
-
export declare function upsertEntityDataProperties(entityDataByTypeName: Map<string, EntityData>, params: EntityDataParams): void;
|
|
95
|
-
export declare function upsertEntityData(entityDataByTypeName: Map<string, EntityData>, incomingData: EntityData): void;
|
|
96
|
-
export type FieldAuthorizationData = {
|
|
97
|
-
fieldName: string;
|
|
98
|
-
requiresAuthentication: boolean;
|
|
99
|
-
requiredScopes: Set<string>[];
|
|
100
|
-
};
|
|
101
|
-
export declare function newFieldAuthorizationData(fieldName: string): FieldAuthorizationData;
|
|
102
|
-
export type AuthorizationData = {
|
|
103
|
-
fieldAuthorizationDataByFieldName: Map<string, FieldAuthorizationData>;
|
|
104
|
-
hasParentLevelAuthorization: boolean;
|
|
105
|
-
requiresAuthentication: boolean;
|
|
106
|
-
requiredScopes: Set<string>[];
|
|
107
|
-
typeName: string;
|
|
108
|
-
};
|
|
109
|
-
export declare function resetAuthorizationData(authorizationData?: AuthorizationData): void;
|
|
110
|
-
export declare function getAuthorizationDataToUpdate(authorizationContainer: AuthorizationData, node: EnumTypeNode | FieldDefinitionNode | InterfaceTypeNode | ObjectTypeNode | ScalarTypeNode): AuthorizationData | FieldAuthorizationData;
|
|
111
|
-
export declare function newAuthorizationData(typeName: string): AuthorizationData;
|
|
112
|
-
export declare const maxOrScopes = 16;
|
|
113
|
-
export declare function mergeAuthorizationDataByAND(source: AuthorizationData | FieldAuthorizationData, target: AuthorizationData | FieldAuthorizationData): boolean;
|
|
114
|
-
export declare function upsertFieldAuthorizationData(fieldAuthorizationDataByFieldName: Map<string, FieldAuthorizationData>, incomingFieldAuthorizationData: FieldAuthorizationData): boolean;
|
|
115
|
-
export declare function upsertAuthorizationData(authorizationDataByParentTypeName: Map<string, AuthorizationData>, incomingAuthorizationData: AuthorizationData, invalidOrScopesFieldPaths: Set<string>): void;
|
|
116
|
-
export declare function upsertAuthorizationConfiguration(fieldConfigurationByFieldPath: Map<string, FieldConfiguration>, authorizationData: AuthorizationData): void;
|
|
117
|
-
export declare function setAndGetValue<K, V>(map: Map<K, V>, key: K, value: V): V;
|
|
118
59
|
export declare function generateSimpleDirective(name: string): ConstDirectiveNode;
|
|
119
60
|
export declare function generateRequiresScopesDirective(orScopes: Set<string>[]): ConstDirectiveNode;
|
|
120
|
-
export declare function isNodeKindInterface(kind: Kind): kind is Kind.INTERFACE_TYPE_DEFINITION | Kind.INTERFACE_TYPE_EXTENSION;
|
|
121
|
-
export declare function isNodeKindObject(kind: Kind): kind is Kind.OBJECT_TYPE_DEFINITION | Kind.OBJECT_TYPE_EXTENSION;
|
|
122
|
-
export declare function addMapEntries<K, V>(source: Map<K, V>, target: Map<K, V>): void;
|
|
123
|
-
export declare function getSingleSetEntry<T>(set: Set<T>): T | undefined;
|
|
124
|
-
export declare function add<T>(set: Set<T>, key: T): boolean;
|
package/dist/utils/utils.js
CHANGED
|
@@ -1,44 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.maxOrScopes = void 0;
|
|
4
3
|
exports.areSetsEqual = areSetsEqual;
|
|
5
4
|
exports.getAllMutualEntries = getAllMutualEntries;
|
|
6
5
|
exports.getOrThrowError = getOrThrowError;
|
|
7
6
|
exports.getAllSetDisparities = getAllSetDisparities;
|
|
8
7
|
exports.getEntriesNotInHashSet = getEntriesNotInHashSet;
|
|
9
|
-
exports.doSetsIntersect = doSetsIntersect;
|
|
10
|
-
exports.subtractSourceSetFromTargetSet = subtractSourceSetFromTargetSet;
|
|
11
|
-
exports.mapToArrayOfValues = mapToArrayOfValues;
|
|
12
8
|
exports.numberToOrdinal = numberToOrdinal;
|
|
13
9
|
exports.addIterableValuesToSet = addIterableValuesToSet;
|
|
14
|
-
exports.addSetsAndReturnMutationBoolean = addSetsAndReturnMutationBoolean;
|
|
15
10
|
exports.kindToTypeString = kindToTypeString;
|
|
16
|
-
exports.kindToConvertedTypeString = kindToConvertedTypeString;
|
|
17
|
-
exports.fieldDatasToSimpleFieldDatas = fieldDatasToSimpleFieldDatas;
|
|
18
|
-
exports.isNodeLeaf = isNodeLeaf;
|
|
19
|
-
exports.newEntityInterfaceFederationData = newEntityInterfaceFederationData;
|
|
20
|
-
exports.upsertEntityInterfaceFederationData = upsertEntityInterfaceFederationData;
|
|
21
11
|
exports.getValueOrDefault = getValueOrDefault;
|
|
22
|
-
exports.
|
|
23
|
-
exports.upsertEntityDataProperties = upsertEntityDataProperties;
|
|
24
|
-
exports.upsertEntityData = upsertEntityData;
|
|
25
|
-
exports.newFieldAuthorizationData = newFieldAuthorizationData;
|
|
26
|
-
exports.resetAuthorizationData = resetAuthorizationData;
|
|
27
|
-
exports.getAuthorizationDataToUpdate = getAuthorizationDataToUpdate;
|
|
28
|
-
exports.newAuthorizationData = newAuthorizationData;
|
|
29
|
-
exports.mergeAuthorizationDataByAND = mergeAuthorizationDataByAND;
|
|
30
|
-
exports.upsertFieldAuthorizationData = upsertFieldAuthorizationData;
|
|
31
|
-
exports.upsertAuthorizationData = upsertAuthorizationData;
|
|
32
|
-
exports.upsertAuthorizationConfiguration = upsertAuthorizationConfiguration;
|
|
33
|
-
exports.setAndGetValue = setAndGetValue;
|
|
12
|
+
exports.add = add;
|
|
34
13
|
exports.generateSimpleDirective = generateSimpleDirective;
|
|
35
14
|
exports.generateRequiresScopesDirective = generateRequiresScopesDirective;
|
|
36
|
-
|
|
37
|
-
exports.isNodeKindObject = isNodeKindObject;
|
|
38
|
-
exports.addMapEntries = addMapEntries;
|
|
39
|
-
exports.getSingleSetEntry = getSingleSetEntry;
|
|
40
|
-
exports.add = add;
|
|
41
|
-
const graphql_1 = require("graphql");
|
|
15
|
+
const index_1 = require("graphql/index");
|
|
42
16
|
const string_constants_1 = require("./string-constants");
|
|
43
17
|
const errors_1 = require("../errors/errors");
|
|
44
18
|
const utils_1 = require("../ast/utils");
|
|
@@ -91,26 +65,6 @@ function getEntriesNotInHashSet(iterable, comparison) {
|
|
|
91
65
|
}
|
|
92
66
|
return disparities;
|
|
93
67
|
}
|
|
94
|
-
function doSetsIntersect(set, other) {
|
|
95
|
-
for (const entry of set) {
|
|
96
|
-
if (other.has(entry)) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return false;
|
|
101
|
-
}
|
|
102
|
-
function subtractSourceSetFromTargetSet(source, target) {
|
|
103
|
-
for (const entry of source) {
|
|
104
|
-
target.delete(entry);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function mapToArrayOfValues(map) {
|
|
108
|
-
const output = [];
|
|
109
|
-
for (const value of map.values()) {
|
|
110
|
-
output.push(value);
|
|
111
|
-
}
|
|
112
|
-
return output;
|
|
113
|
-
}
|
|
114
68
|
function numberToOrdinal(num) {
|
|
115
69
|
const numString = num.toString();
|
|
116
70
|
const lastNumber = numString[numString.length - 1];
|
|
@@ -130,223 +84,76 @@ function addIterableValuesToSet(source, target) {
|
|
|
130
84
|
target.add(value);
|
|
131
85
|
}
|
|
132
86
|
}
|
|
133
|
-
function addSetsAndReturnMutationBoolean(source, target) {
|
|
134
|
-
let wasMutated = false;
|
|
135
|
-
for (const entry of source) {
|
|
136
|
-
if (target.has(entry)) {
|
|
137
|
-
continue;
|
|
138
|
-
}
|
|
139
|
-
wasMutated = true;
|
|
140
|
-
target.add(entry);
|
|
141
|
-
}
|
|
142
|
-
return wasMutated;
|
|
143
|
-
}
|
|
144
87
|
function kindToTypeString(kind) {
|
|
145
88
|
switch (kind) {
|
|
146
|
-
case
|
|
89
|
+
case index_1.Kind.BOOLEAN: {
|
|
147
90
|
return string_constants_1.BOOLEAN_SCALAR;
|
|
148
91
|
}
|
|
149
|
-
case
|
|
92
|
+
case index_1.Kind.ENUM:
|
|
150
93
|
// intentional fallthrough
|
|
151
|
-
case
|
|
94
|
+
case index_1.Kind.ENUM_TYPE_DEFINITION: {
|
|
152
95
|
return string_constants_1.ENUM;
|
|
153
96
|
}
|
|
154
|
-
case
|
|
97
|
+
case index_1.Kind.ENUM_TYPE_EXTENSION: {
|
|
155
98
|
return 'Enum extension';
|
|
156
99
|
}
|
|
157
|
-
case
|
|
100
|
+
case index_1.Kind.ENUM_VALUE_DEFINITION: {
|
|
158
101
|
return string_constants_1.ENUM_VALUE;
|
|
159
102
|
}
|
|
160
|
-
case
|
|
103
|
+
case index_1.Kind.FIELD_DEFINITION: {
|
|
161
104
|
return string_constants_1.FIELD;
|
|
162
105
|
}
|
|
163
|
-
case
|
|
106
|
+
case index_1.Kind.FLOAT: {
|
|
164
107
|
return string_constants_1.FLOAT_SCALAR;
|
|
165
108
|
}
|
|
166
|
-
case
|
|
109
|
+
case index_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: {
|
|
167
110
|
return string_constants_1.INPUT_OBJECT;
|
|
168
111
|
}
|
|
169
|
-
case
|
|
112
|
+
case index_1.Kind.INPUT_OBJECT_TYPE_EXTENSION: {
|
|
170
113
|
return 'Input Object extension';
|
|
171
114
|
}
|
|
172
|
-
case
|
|
115
|
+
case index_1.Kind.INPUT_VALUE_DEFINITION: {
|
|
173
116
|
return string_constants_1.INPUT_VALUE;
|
|
174
117
|
}
|
|
175
|
-
case
|
|
118
|
+
case index_1.Kind.INT: {
|
|
176
119
|
return string_constants_1.INT_SCALAR;
|
|
177
120
|
}
|
|
178
|
-
case
|
|
121
|
+
case index_1.Kind.INTERFACE_TYPE_DEFINITION: {
|
|
179
122
|
return string_constants_1.INTERFACE;
|
|
180
123
|
}
|
|
181
|
-
case
|
|
124
|
+
case index_1.Kind.INTERFACE_TYPE_EXTENSION: {
|
|
182
125
|
return 'Interface extension';
|
|
183
126
|
}
|
|
184
|
-
case
|
|
127
|
+
case index_1.Kind.NULL: {
|
|
185
128
|
return string_constants_1.NULL;
|
|
186
129
|
}
|
|
187
|
-
case
|
|
130
|
+
case index_1.Kind.OBJECT:
|
|
188
131
|
// intentional fallthrough
|
|
189
|
-
case
|
|
132
|
+
case index_1.Kind.OBJECT_TYPE_DEFINITION: {
|
|
190
133
|
return string_constants_1.OBJECT;
|
|
191
134
|
}
|
|
192
|
-
case
|
|
135
|
+
case index_1.Kind.OBJECT_TYPE_EXTENSION: {
|
|
193
136
|
return 'Object extension';
|
|
194
137
|
}
|
|
195
|
-
case
|
|
138
|
+
case index_1.Kind.STRING: {
|
|
196
139
|
return string_constants_1.STRING_SCALAR;
|
|
197
140
|
}
|
|
198
|
-
case
|
|
141
|
+
case index_1.Kind.SCALAR_TYPE_DEFINITION: {
|
|
199
142
|
return string_constants_1.SCALAR;
|
|
200
143
|
}
|
|
201
|
-
case
|
|
144
|
+
case index_1.Kind.SCALAR_TYPE_EXTENSION: {
|
|
202
145
|
return 'Scalar extension';
|
|
203
146
|
}
|
|
204
|
-
case
|
|
147
|
+
case index_1.Kind.UNION_TYPE_DEFINITION: {
|
|
205
148
|
return string_constants_1.UNION;
|
|
206
149
|
}
|
|
207
|
-
case
|
|
150
|
+
case index_1.Kind.UNION_TYPE_EXTENSION: {
|
|
208
151
|
return 'Union extension';
|
|
209
152
|
}
|
|
210
153
|
default:
|
|
211
154
|
return kind;
|
|
212
155
|
}
|
|
213
156
|
}
|
|
214
|
-
function kindToConvertedTypeString(kind) {
|
|
215
|
-
switch (kind) {
|
|
216
|
-
case graphql_1.Kind.BOOLEAN: {
|
|
217
|
-
return string_constants_1.BOOLEAN_SCALAR;
|
|
218
|
-
}
|
|
219
|
-
case graphql_1.Kind.ENUM:
|
|
220
|
-
// intentional fallthrough
|
|
221
|
-
case graphql_1.Kind.ENUM_TYPE_DEFINITION:
|
|
222
|
-
// intentional fallthrough
|
|
223
|
-
case graphql_1.Kind.ENUM_TYPE_EXTENSION: {
|
|
224
|
-
return string_constants_1.ENUM;
|
|
225
|
-
}
|
|
226
|
-
case graphql_1.Kind.ENUM_VALUE_DEFINITION: {
|
|
227
|
-
return string_constants_1.ENUM_VALUE;
|
|
228
|
-
}
|
|
229
|
-
case graphql_1.Kind.FIELD_DEFINITION: {
|
|
230
|
-
return string_constants_1.FIELD;
|
|
231
|
-
}
|
|
232
|
-
case graphql_1.Kind.FLOAT: {
|
|
233
|
-
return string_constants_1.FLOAT_SCALAR;
|
|
234
|
-
}
|
|
235
|
-
case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION:
|
|
236
|
-
// intentional fallthrough
|
|
237
|
-
case graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION: {
|
|
238
|
-
return string_constants_1.INPUT_OBJECT;
|
|
239
|
-
}
|
|
240
|
-
case graphql_1.Kind.INPUT_VALUE_DEFINITION: {
|
|
241
|
-
return string_constants_1.INPUT_VALUE;
|
|
242
|
-
}
|
|
243
|
-
case graphql_1.Kind.INT: {
|
|
244
|
-
return string_constants_1.INT_SCALAR;
|
|
245
|
-
}
|
|
246
|
-
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
247
|
-
// intentional fallthrough
|
|
248
|
-
case graphql_1.Kind.INTERFACE_TYPE_EXTENSION: {
|
|
249
|
-
return string_constants_1.INTERFACE;
|
|
250
|
-
}
|
|
251
|
-
case graphql_1.Kind.NULL: {
|
|
252
|
-
return string_constants_1.NULL;
|
|
253
|
-
}
|
|
254
|
-
case graphql_1.Kind.OBJECT:
|
|
255
|
-
// intentional fallthrough
|
|
256
|
-
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
257
|
-
// intentional fallthrough
|
|
258
|
-
case graphql_1.Kind.OBJECT_TYPE_EXTENSION: {
|
|
259
|
-
return string_constants_1.OBJECT;
|
|
260
|
-
}
|
|
261
|
-
case graphql_1.Kind.STRING: {
|
|
262
|
-
return string_constants_1.STRING_SCALAR;
|
|
263
|
-
}
|
|
264
|
-
case graphql_1.Kind.SCALAR_TYPE_DEFINITION:
|
|
265
|
-
// intentional fallthrough
|
|
266
|
-
case graphql_1.Kind.SCALAR_TYPE_EXTENSION: {
|
|
267
|
-
return string_constants_1.SCALAR;
|
|
268
|
-
}
|
|
269
|
-
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
270
|
-
// intentional fallthrough
|
|
271
|
-
case graphql_1.Kind.UNION_TYPE_EXTENSION: {
|
|
272
|
-
return string_constants_1.UNION;
|
|
273
|
-
}
|
|
274
|
-
default:
|
|
275
|
-
return kind;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function fieldDatasToSimpleFieldDatas(fieldDatas) {
|
|
279
|
-
const simpleFieldDatas = [];
|
|
280
|
-
for (const { name, namedTypeName } of fieldDatas) {
|
|
281
|
-
simpleFieldDatas.push({ name, namedTypeName });
|
|
282
|
-
}
|
|
283
|
-
return simpleFieldDatas;
|
|
284
|
-
}
|
|
285
|
-
// Only used to assess the output type of field definitions for graph selection set rendering
|
|
286
|
-
function isNodeLeaf(kind) {
|
|
287
|
-
// Base scalars are not added to parent definition data
|
|
288
|
-
if (!kind) {
|
|
289
|
-
return true;
|
|
290
|
-
}
|
|
291
|
-
switch (kind) {
|
|
292
|
-
case graphql_1.Kind.OBJECT_TYPE_DEFINITION:
|
|
293
|
-
case graphql_1.Kind.INTERFACE_TYPE_DEFINITION:
|
|
294
|
-
case graphql_1.Kind.UNION_TYPE_DEFINITION:
|
|
295
|
-
return false;
|
|
296
|
-
default:
|
|
297
|
-
return true;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function newEntityInterfaceFederationData(entityInterfaceData, subgraphName) {
|
|
301
|
-
return {
|
|
302
|
-
fieldDatasBySubgraphName: new Map().set(subgraphName, entityInterfaceData.fieldDatas),
|
|
303
|
-
interfaceFieldNames: new Set(entityInterfaceData.interfaceFieldNames),
|
|
304
|
-
interfaceObjectFieldNames: new Set(entityInterfaceData.interfaceObjectFieldNames),
|
|
305
|
-
interfaceObjectSubgraphs: new Set(entityInterfaceData.isInterfaceObject ? [subgraphName] : []),
|
|
306
|
-
typeName: entityInterfaceData.typeName,
|
|
307
|
-
...(entityInterfaceData.isInterfaceObject
|
|
308
|
-
? {}
|
|
309
|
-
: { concreteTypeNames: new Set(entityInterfaceData.concreteTypeNames) }),
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
// Returns true if the federation data concrete types set was mutated and false otherwise
|
|
313
|
-
function upsertEntityInterfaceFederationData(federationData, subgraphData, subgraphName) {
|
|
314
|
-
federationData.fieldDatasBySubgraphName.set(subgraphName, subgraphData.fieldDatas);
|
|
315
|
-
addIterableValuesToSet(subgraphData.interfaceFieldNames, federationData.interfaceFieldNames);
|
|
316
|
-
addIterableValuesToSet(subgraphData.interfaceObjectFieldNames, federationData.interfaceObjectFieldNames);
|
|
317
|
-
// interface objects should not define any concrete types
|
|
318
|
-
if (subgraphData.isInterfaceObject) {
|
|
319
|
-
federationData.interfaceObjectSubgraphs.add(subgraphName);
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
// the concreteTypeNames set is null if only interfaceObjects have been encountered
|
|
323
|
-
if (!federationData.concreteTypeNames) {
|
|
324
|
-
federationData.concreteTypeNames = new Set(subgraphData.concreteTypeNames);
|
|
325
|
-
return false;
|
|
326
|
-
}
|
|
327
|
-
// entity interface concrete types should be consistent
|
|
328
|
-
return addSetsAndReturnMutationBoolean(subgraphData.concreteTypeNames || new Set(), federationData.concreteTypeNames);
|
|
329
|
-
}
|
|
330
|
-
class StackSet {
|
|
331
|
-
set = new Set();
|
|
332
|
-
stack = [];
|
|
333
|
-
constructor(value) {
|
|
334
|
-
this.push(value);
|
|
335
|
-
}
|
|
336
|
-
has(value) {
|
|
337
|
-
return this.set.has(value);
|
|
338
|
-
}
|
|
339
|
-
push(value) {
|
|
340
|
-
this.stack.push(value);
|
|
341
|
-
this.set.add(value);
|
|
342
|
-
}
|
|
343
|
-
pop() {
|
|
344
|
-
const value = this.stack.pop();
|
|
345
|
-
if (value) {
|
|
346
|
-
this.set.delete(value);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
157
|
function getValueOrDefault(map, key, constructor) {
|
|
351
158
|
const existingValue = map.get(key);
|
|
352
159
|
if (existingValue) {
|
|
@@ -356,153 +163,16 @@ function getValueOrDefault(map, key, constructor) {
|
|
|
356
163
|
map.set(key, value);
|
|
357
164
|
return value;
|
|
358
165
|
}
|
|
359
|
-
function
|
|
360
|
-
|
|
361
|
-
fieldNames: new Set(params.fieldNames),
|
|
362
|
-
keyFieldSets: new Set(params.keyFieldSets),
|
|
363
|
-
subgraphNames: new Set(params.subgraphNames),
|
|
364
|
-
typeName: params.typeName,
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
function addEntityDataProperties(source, target) {
|
|
368
|
-
addIterableValuesToSet(source.fieldNames || [], target.fieldNames);
|
|
369
|
-
addIterableValuesToSet(source.keyFieldSets || [], target.keyFieldSets);
|
|
370
|
-
addIterableValuesToSet(source.subgraphNames || [], target.subgraphNames);
|
|
371
|
-
}
|
|
372
|
-
function upsertEntityDataProperties(entityDataByTypeName, params) {
|
|
373
|
-
const existingData = entityDataByTypeName.get(params.typeName);
|
|
374
|
-
existingData
|
|
375
|
-
? addEntityDataProperties(params, existingData)
|
|
376
|
-
: entityDataByTypeName.set(params.typeName, newEntityData(params));
|
|
377
|
-
}
|
|
378
|
-
function upsertEntityData(entityDataByTypeName, incomingData) {
|
|
379
|
-
const existingData = entityDataByTypeName.get(incomingData.typeName);
|
|
380
|
-
existingData
|
|
381
|
-
? addEntityDataProperties(incomingData, existingData)
|
|
382
|
-
: entityDataByTypeName.set(incomingData.typeName, incomingData);
|
|
383
|
-
}
|
|
384
|
-
function newFieldAuthorizationData(fieldName) {
|
|
385
|
-
return {
|
|
386
|
-
fieldName,
|
|
387
|
-
requiresAuthentication: false,
|
|
388
|
-
requiredScopes: [],
|
|
389
|
-
};
|
|
390
|
-
}
|
|
391
|
-
function resetAuthorizationData(authorizationData) {
|
|
392
|
-
if (!authorizationData) {
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
authorizationData.requiresAuthentication = false;
|
|
396
|
-
authorizationData.requiredScopes = [];
|
|
397
|
-
authorizationData.hasParentLevelAuthorization = false;
|
|
398
|
-
}
|
|
399
|
-
function getAuthorizationDataToUpdate(authorizationContainer, node) {
|
|
400
|
-
if (node.kind === graphql_1.Kind.FIELD_DEFINITION) {
|
|
401
|
-
const name = node.name.value;
|
|
402
|
-
return getValueOrDefault(authorizationContainer.fieldAuthorizationDataByFieldName, name, () => newFieldAuthorizationData(name));
|
|
403
|
-
}
|
|
404
|
-
authorizationContainer.hasParentLevelAuthorization = true;
|
|
405
|
-
return authorizationContainer;
|
|
406
|
-
}
|
|
407
|
-
function newAuthorizationData(typeName) {
|
|
408
|
-
return {
|
|
409
|
-
fieldAuthorizationDataByFieldName: new Map(),
|
|
410
|
-
hasParentLevelAuthorization: false,
|
|
411
|
-
requiresAuthentication: false,
|
|
412
|
-
requiredScopes: [],
|
|
413
|
-
typeName,
|
|
414
|
-
};
|
|
415
|
-
}
|
|
416
|
-
exports.maxOrScopes = 16;
|
|
417
|
-
function mergeAuthorizationDataByAND(source, target) {
|
|
418
|
-
target.requiresAuthentication ||= source.requiresAuthentication;
|
|
419
|
-
const sourceScopesLength = source.requiredScopes.length;
|
|
420
|
-
if (sourceScopesLength < 1) {
|
|
421
|
-
return true;
|
|
422
|
-
}
|
|
423
|
-
const targetScopesLength = target.requiredScopes.length;
|
|
424
|
-
if (targetScopesLength < 1) {
|
|
425
|
-
if (sourceScopesLength > exports.maxOrScopes) {
|
|
426
|
-
return false;
|
|
427
|
-
}
|
|
428
|
-
for (const andScopes of source.requiredScopes) {
|
|
429
|
-
target.requiredScopes.push(new Set(andScopes));
|
|
430
|
-
}
|
|
431
|
-
return true;
|
|
432
|
-
}
|
|
433
|
-
if (sourceScopesLength * targetScopesLength > exports.maxOrScopes) {
|
|
166
|
+
function add(set, key) {
|
|
167
|
+
if (set.has(key)) {
|
|
434
168
|
return false;
|
|
435
169
|
}
|
|
436
|
-
|
|
437
|
-
for (const existingAndScopes of target.requiredScopes) {
|
|
438
|
-
for (const incomingAndScopes of source.requiredScopes) {
|
|
439
|
-
const newAndScopes = new Set(existingAndScopes);
|
|
440
|
-
addIterableValuesToSet(incomingAndScopes, newAndScopes);
|
|
441
|
-
mergedOrScopes.push(newAndScopes);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
target.requiredScopes = mergedOrScopes;
|
|
170
|
+
set.add(key);
|
|
445
171
|
return true;
|
|
446
172
|
}
|
|
447
|
-
function upsertFieldAuthorizationData(fieldAuthorizationDataByFieldName, incomingFieldAuthorizationData) {
|
|
448
|
-
const fieldName = incomingFieldAuthorizationData.fieldName;
|
|
449
|
-
const existingFieldAuthorizationData = fieldAuthorizationDataByFieldName.get(fieldName);
|
|
450
|
-
if (!existingFieldAuthorizationData) {
|
|
451
|
-
if (incomingFieldAuthorizationData.requiredScopes.length > exports.maxOrScopes) {
|
|
452
|
-
return false;
|
|
453
|
-
}
|
|
454
|
-
const fieldAuthorizationData = newFieldAuthorizationData(fieldName);
|
|
455
|
-
fieldAuthorizationData.requiresAuthentication ||= incomingFieldAuthorizationData.requiresAuthentication;
|
|
456
|
-
for (const andScopes of incomingFieldAuthorizationData.requiredScopes) {
|
|
457
|
-
fieldAuthorizationData.requiredScopes.push(new Set(andScopes));
|
|
458
|
-
}
|
|
459
|
-
fieldAuthorizationDataByFieldName.set(fieldName, fieldAuthorizationData);
|
|
460
|
-
return true;
|
|
461
|
-
}
|
|
462
|
-
existingFieldAuthorizationData.requiresAuthentication ||= incomingFieldAuthorizationData.requiresAuthentication;
|
|
463
|
-
return mergeAuthorizationDataByAND(incomingFieldAuthorizationData, existingFieldAuthorizationData);
|
|
464
|
-
}
|
|
465
|
-
function upsertAuthorizationData(authorizationDataByParentTypeName, incomingAuthorizationData, invalidOrScopesFieldPaths) {
|
|
466
|
-
const existingAuthorizationData = authorizationDataByParentTypeName.get(incomingAuthorizationData.typeName);
|
|
467
|
-
if (!existingAuthorizationData) {
|
|
468
|
-
authorizationDataByParentTypeName.set(incomingAuthorizationData.typeName, incomingAuthorizationData);
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
|
-
for (const [fieldName, fieldAuthorizationData] of incomingAuthorizationData.fieldAuthorizationDataByFieldName) {
|
|
472
|
-
if (!upsertFieldAuthorizationData(existingAuthorizationData.fieldAuthorizationDataByFieldName, fieldAuthorizationData)) {
|
|
473
|
-
invalidOrScopesFieldPaths.add(`${incomingAuthorizationData.typeName}.${fieldName}`);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
function upsertAuthorizationConfiguration(fieldConfigurationByFieldPath, authorizationData) {
|
|
478
|
-
const typeName = authorizationData.typeName;
|
|
479
|
-
for (const [fieldName, fieldAuthorizationData] of authorizationData.fieldAuthorizationDataByFieldName) {
|
|
480
|
-
const fieldPath = `${typeName}.${fieldName}`;
|
|
481
|
-
const existingFieldConfiguration = fieldConfigurationByFieldPath.get(fieldPath);
|
|
482
|
-
if (existingFieldConfiguration) {
|
|
483
|
-
existingFieldConfiguration.requiresAuthentication = fieldAuthorizationData.requiresAuthentication;
|
|
484
|
-
existingFieldConfiguration.requiredScopes = fieldAuthorizationData.requiredScopes.map((orScopes) => [
|
|
485
|
-
...orScopes,
|
|
486
|
-
]);
|
|
487
|
-
}
|
|
488
|
-
else {
|
|
489
|
-
fieldConfigurationByFieldPath.set(fieldPath, {
|
|
490
|
-
argumentNames: [],
|
|
491
|
-
typeName,
|
|
492
|
-
fieldName,
|
|
493
|
-
requiresAuthentication: fieldAuthorizationData.requiresAuthentication,
|
|
494
|
-
requiredScopes: fieldAuthorizationData.requiredScopes.map((orScopes) => [...orScopes]),
|
|
495
|
-
});
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
function setAndGetValue(map, key, value) {
|
|
500
|
-
map.set(key, value);
|
|
501
|
-
return value;
|
|
502
|
-
}
|
|
503
173
|
function generateSimpleDirective(name) {
|
|
504
174
|
return {
|
|
505
|
-
kind:
|
|
175
|
+
kind: index_1.Kind.DIRECTIVE,
|
|
506
176
|
name: (0, utils_1.stringToNameNode)(name),
|
|
507
177
|
};
|
|
508
178
|
}
|
|
@@ -512,48 +182,25 @@ function generateRequiresScopesDirective(orScopes) {
|
|
|
512
182
|
const scopes = [];
|
|
513
183
|
for (const scope of andScopes) {
|
|
514
184
|
scopes.push({
|
|
515
|
-
kind:
|
|
185
|
+
kind: index_1.Kind.STRING,
|
|
516
186
|
value: scope,
|
|
517
187
|
});
|
|
518
188
|
}
|
|
519
|
-
values.push({ kind:
|
|
189
|
+
values.push({ kind: index_1.Kind.LIST, values: scopes });
|
|
520
190
|
}
|
|
521
191
|
return {
|
|
522
|
-
kind:
|
|
192
|
+
kind: index_1.Kind.DIRECTIVE,
|
|
523
193
|
name: (0, utils_1.stringToNameNode)(string_constants_1.REQUIRES_SCOPES),
|
|
524
194
|
arguments: [
|
|
525
195
|
{
|
|
526
|
-
kind:
|
|
196
|
+
kind: index_1.Kind.ARGUMENT,
|
|
527
197
|
name: (0, utils_1.stringToNameNode)(string_constants_1.SCOPES),
|
|
528
198
|
value: {
|
|
529
|
-
kind:
|
|
199
|
+
kind: index_1.Kind.LIST,
|
|
530
200
|
values,
|
|
531
201
|
},
|
|
532
202
|
},
|
|
533
203
|
],
|
|
534
204
|
};
|
|
535
205
|
}
|
|
536
|
-
function isNodeKindInterface(kind) {
|
|
537
|
-
return kind === graphql_1.Kind.INTERFACE_TYPE_DEFINITION || kind === graphql_1.Kind.INTERFACE_TYPE_EXTENSION;
|
|
538
|
-
}
|
|
539
|
-
function isNodeKindObject(kind) {
|
|
540
|
-
return kind === graphql_1.Kind.OBJECT_TYPE_DEFINITION || kind === graphql_1.Kind.OBJECT_TYPE_EXTENSION;
|
|
541
|
-
}
|
|
542
|
-
function addMapEntries(source, target) {
|
|
543
|
-
for (const [key, value] of source) {
|
|
544
|
-
target.set(key, value);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
function getSingleSetEntry(set) {
|
|
548
|
-
for (const entry of set) {
|
|
549
|
-
return entry;
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
function add(set, key) {
|
|
553
|
-
if (set.has(key)) {
|
|
554
|
-
return false;
|
|
555
|
-
}
|
|
556
|
-
set.add(key);
|
|
557
|
-
return true;
|
|
558
|
-
}
|
|
559
206
|
//# sourceMappingURL=utils.js.map
|