@theguild/federation-composition 0.21.3-alpha-20260113121415-bf20f64cd15d5043b10d499b094f1064eae2ea2f → 0.21.3
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/subgraph/validation/validate-subgraph.js +0 -2
- package/cjs/supergraph/validation/rules/auth-on-requires-rule.js +10 -1
- package/esm/subgraph/validation/validate-subgraph.js +0 -2
- package/esm/supergraph/validation/rules/auth-on-requires-rule.js +10 -1
- package/package.json +1 -1
- package/cjs/subgraph/validation/rules/link-spec-reserved-type-names-rule.js +0 -35
- package/esm/subgraph/validation/rules/link-spec-reserved-type-names-rule.js +0 -32
- package/typings/subgraph/validation/rules/link-spec-reserved-type-names-rule.d.cts +0 -4
- package/typings/subgraph/validation/rules/link-spec-reserved-type-names-rule.d.ts +0 -4
|
@@ -47,7 +47,6 @@ const unique_field_definition_names_rule_js_1 = require("./rules/unique-field-de
|
|
|
47
47
|
const unique_input_field_names_rule_js_1 = require("./rules/unique-input-field-names-rule.js");
|
|
48
48
|
const unique_operation_types_rule_js_1 = require("./rules/unique-operation-types-rule.js");
|
|
49
49
|
const unique_type_names_rule_js_1 = require("./rules/unique-type-names-rule.js");
|
|
50
|
-
const link_spec_reserved_type_names_rule_js_1 = require("./rules/link-spec-reserved-type-names-rule.js");
|
|
51
50
|
const validate_state_js_1 = require("./validate-state.js");
|
|
52
51
|
const validation_context_js_1 = require("./validation-context.js");
|
|
53
52
|
function assertUniqueSubgraphNames(subgraphs) {
|
|
@@ -100,7 +99,6 @@ function validateSubgraph(subgraph, stateBuilder, federation, __internal) {
|
|
|
100
99
|
const validationContext = (0, validation_context_js_1.createSubgraphValidationContext)(subgraph, federation, typeNodeInfo, stateBuilder);
|
|
101
100
|
const federationRules = [
|
|
102
101
|
reserved_subgraph_name_rule_js_1.ReservedSubgraphNameRule,
|
|
103
|
-
link_spec_reserved_type_names_rule_js_1.LinkSpecReservedTypeNamesRule,
|
|
104
102
|
known_federation_directive_rule_js_1.KnownFederationDirectivesRule,
|
|
105
103
|
field_set_js_1.FieldSetRules,
|
|
106
104
|
inaccessible_js_1.InaccessibleRules,
|
|
@@ -30,7 +30,16 @@ function ensureAccessToSelectionSet(supergraph, currentType, selectionSet, provi
|
|
|
30
30
|
switch (selection.kind) {
|
|
31
31
|
case graphql_1.Kind.FIELD: {
|
|
32
32
|
if (currentType.kind === "union") {
|
|
33
|
-
|
|
33
|
+
if (selection.name.value !== "__typename") {
|
|
34
|
+
throw new Error("Cannot select fields directly on union types.");
|
|
35
|
+
}
|
|
36
|
+
for (const memberTypeName of currentType.members) {
|
|
37
|
+
const memberType = supergraph.objectTypes.get(memberTypeName);
|
|
38
|
+
if (memberType && !provisionedAccess.canAccess(memberType)) {
|
|
39
|
+
return memberTypeName;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
34
43
|
}
|
|
35
44
|
const fieldLackingAccess = ensureAccessToField(supergraph, currentType, selection, provisionedAccess);
|
|
36
45
|
if (fieldLackingAccess) {
|
|
@@ -42,7 +42,6 @@ import { UniqueFieldDefinitionNamesRule } from "./rules/unique-field-definition-
|
|
|
42
42
|
import { UniqueInputFieldNamesRule } from "./rules/unique-input-field-names-rule.js";
|
|
43
43
|
import { UniqueOperationTypesRule } from "./rules/unique-operation-types-rule.js";
|
|
44
44
|
import { UniqueTypeNamesRule } from "./rules/unique-type-names-rule.js";
|
|
45
|
-
import { LinkSpecReservedTypeNamesRule } from "./rules/link-spec-reserved-type-names-rule.js";
|
|
46
45
|
import { validateSubgraphState } from "./validate-state.js";
|
|
47
46
|
import { createSimpleValidationContext, createSubgraphValidationContext, } from "./validation-context.js";
|
|
48
47
|
export function assertUniqueSubgraphNames(subgraphs) {
|
|
@@ -95,7 +94,6 @@ export function validateSubgraph(subgraph, stateBuilder, federation, __internal)
|
|
|
95
94
|
const validationContext = createSubgraphValidationContext(subgraph, federation, typeNodeInfo, stateBuilder);
|
|
96
95
|
const federationRules = [
|
|
97
96
|
ReservedSubgraphNameRule,
|
|
98
|
-
LinkSpecReservedTypeNamesRule,
|
|
99
97
|
KnownFederationDirectivesRule,
|
|
100
98
|
FieldSetRules,
|
|
101
99
|
InaccessibleRules,
|
|
@@ -27,7 +27,16 @@ function ensureAccessToSelectionSet(supergraph, currentType, selectionSet, provi
|
|
|
27
27
|
switch (selection.kind) {
|
|
28
28
|
case Kind.FIELD: {
|
|
29
29
|
if (currentType.kind === "union") {
|
|
30
|
-
|
|
30
|
+
if (selection.name.value !== "__typename") {
|
|
31
|
+
throw new Error("Cannot select fields directly on union types.");
|
|
32
|
+
}
|
|
33
|
+
for (const memberTypeName of currentType.members) {
|
|
34
|
+
const memberType = supergraph.objectTypes.get(memberTypeName);
|
|
35
|
+
if (memberType && !provisionedAccess.canAccess(memberType)) {
|
|
36
|
+
return memberTypeName;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
31
40
|
}
|
|
32
41
|
const fieldLackingAccess = ensureAccessToField(supergraph, currentType, selection, provisionedAccess);
|
|
33
42
|
if (fieldLackingAccess) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theguild/federation-composition",
|
|
3
|
-
"version": "0.21.3
|
|
3
|
+
"version": "0.21.3",
|
|
4
4
|
"description": "Open Source Composition library for Apollo Federation",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^16.0.0"
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LinkSpecReservedTypeNamesRule = LinkSpecReservedTypeNamesRule;
|
|
4
|
-
const graphql_1 = require("graphql");
|
|
5
|
-
const LINK_SPEC_RESERVED_TYPE_NAMES = new Set(["Purpose", "Import"]);
|
|
6
|
-
function LinkSpecReservedTypeNamesRule(context) {
|
|
7
|
-
if (!context.satisfiesVersionRange("> v1.0")) {
|
|
8
|
-
return {};
|
|
9
|
-
}
|
|
10
|
-
function checkTypeName(node) {
|
|
11
|
-
const typeName = node.name.value;
|
|
12
|
-
if (LINK_SPEC_RESERVED_TYPE_NAMES.has(typeName)) {
|
|
13
|
-
context.reportError(new graphql_1.GraphQLError(`Type "${typeName}" is reserved by the Apollo Link spec (https://specs.apollo.dev/link/v1.0/). Please rename your type.`, {
|
|
14
|
-
nodes: node,
|
|
15
|
-
extensions: {
|
|
16
|
-
code: "LINK_SPEC_RESERVED_TYPE_NAME",
|
|
17
|
-
},
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
ScalarTypeDefinition: checkTypeName,
|
|
23
|
-
ScalarTypeExtension: checkTypeName,
|
|
24
|
-
ObjectTypeDefinition: checkTypeName,
|
|
25
|
-
ObjectTypeExtension: checkTypeName,
|
|
26
|
-
InterfaceTypeDefinition: checkTypeName,
|
|
27
|
-
InterfaceTypeExtension: checkTypeName,
|
|
28
|
-
UnionTypeDefinition: checkTypeName,
|
|
29
|
-
UnionTypeExtension: checkTypeName,
|
|
30
|
-
EnumTypeDefinition: checkTypeName,
|
|
31
|
-
EnumTypeExtension: checkTypeName,
|
|
32
|
-
InputObjectTypeDefinition: checkTypeName,
|
|
33
|
-
InputObjectTypeExtension: checkTypeName,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { GraphQLError, } from "graphql";
|
|
2
|
-
const LINK_SPEC_RESERVED_TYPE_NAMES = new Set(["Purpose", "Import"]);
|
|
3
|
-
export function LinkSpecReservedTypeNamesRule(context) {
|
|
4
|
-
if (!context.satisfiesVersionRange("> v1.0")) {
|
|
5
|
-
return {};
|
|
6
|
-
}
|
|
7
|
-
function checkTypeName(node) {
|
|
8
|
-
const typeName = node.name.value;
|
|
9
|
-
if (LINK_SPEC_RESERVED_TYPE_NAMES.has(typeName)) {
|
|
10
|
-
context.reportError(new GraphQLError(`Type "${typeName}" is reserved by the Apollo Link spec (https://specs.apollo.dev/link/v1.0/). Please rename your type.`, {
|
|
11
|
-
nodes: node,
|
|
12
|
-
extensions: {
|
|
13
|
-
code: "LINK_SPEC_RESERVED_TYPE_NAME",
|
|
14
|
-
},
|
|
15
|
-
}));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return {
|
|
19
|
-
ScalarTypeDefinition: checkTypeName,
|
|
20
|
-
ScalarTypeExtension: checkTypeName,
|
|
21
|
-
ObjectTypeDefinition: checkTypeName,
|
|
22
|
-
ObjectTypeExtension: checkTypeName,
|
|
23
|
-
InterfaceTypeDefinition: checkTypeName,
|
|
24
|
-
InterfaceTypeExtension: checkTypeName,
|
|
25
|
-
UnionTypeDefinition: checkTypeName,
|
|
26
|
-
UnionTypeExtension: checkTypeName,
|
|
27
|
-
EnumTypeDefinition: checkTypeName,
|
|
28
|
-
EnumTypeExtension: checkTypeName,
|
|
29
|
-
InputObjectTypeDefinition: checkTypeName,
|
|
30
|
-
InputObjectTypeExtension: checkTypeName,
|
|
31
|
-
};
|
|
32
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ASTVisitor } from "graphql";
|
|
2
|
-
import type { SubgraphValidationContext } from "../validation-context.cjs";
|
|
3
|
-
export declare function LinkSpecReservedTypeNamesRule(context: SubgraphValidationContext): ASTVisitor;
|
|
4
|
-
//# sourceMappingURL=link-spec-reserved-type-names-rule.d.ts.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ASTVisitor } from "graphql";
|
|
2
|
-
import type { SubgraphValidationContext } from "../validation-context.js";
|
|
3
|
-
export declare function LinkSpecReservedTypeNamesRule(context: SubgraphValidationContext): ASTVisitor;
|
|
4
|
-
//# sourceMappingURL=link-spec-reserved-type-names-rule.d.ts.map
|