@theguild/federation-composition 0.21.2 → 0.21.3-alpha-20260113121415-bf20f64cd15d5043b10d499b094f1064eae2ea2f
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/rules/link-spec-reserved-type-names-rule.js +35 -0
- package/cjs/subgraph/validation/validate-subgraph.js +2 -0
- package/esm/subgraph/validation/rules/link-spec-reserved-type-names-rule.js +32 -0
- package/esm/subgraph/validation/validate-subgraph.js +2 -0
- package/package.json +1 -1
- package/typings/subgraph/validation/rules/link-spec-reserved-type-names-rule.d.cts +4 -0
- package/typings/subgraph/validation/rules/link-spec-reserved-type-names-rule.d.ts +4 -0
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
}
|
|
@@ -47,6 +47,7 @@ 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");
|
|
50
51
|
const validate_state_js_1 = require("./validate-state.js");
|
|
51
52
|
const validation_context_js_1 = require("./validation-context.js");
|
|
52
53
|
function assertUniqueSubgraphNames(subgraphs) {
|
|
@@ -99,6 +100,7 @@ function validateSubgraph(subgraph, stateBuilder, federation, __internal) {
|
|
|
99
100
|
const validationContext = (0, validation_context_js_1.createSubgraphValidationContext)(subgraph, federation, typeNodeInfo, stateBuilder);
|
|
100
101
|
const federationRules = [
|
|
101
102
|
reserved_subgraph_name_rule_js_1.ReservedSubgraphNameRule,
|
|
103
|
+
link_spec_reserved_type_names_rule_js_1.LinkSpecReservedTypeNamesRule,
|
|
102
104
|
known_federation_directive_rule_js_1.KnownFederationDirectivesRule,
|
|
103
105
|
field_set_js_1.FieldSetRules,
|
|
104
106
|
inaccessible_js_1.InaccessibleRules,
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
}
|
|
@@ -42,6 +42,7 @@ 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";
|
|
45
46
|
import { validateSubgraphState } from "./validate-state.js";
|
|
46
47
|
import { createSimpleValidationContext, createSubgraphValidationContext, } from "./validation-context.js";
|
|
47
48
|
export function assertUniqueSubgraphNames(subgraphs) {
|
|
@@ -94,6 +95,7 @@ export function validateSubgraph(subgraph, stateBuilder, federation, __internal)
|
|
|
94
95
|
const validationContext = createSubgraphValidationContext(subgraph, federation, typeNodeInfo, stateBuilder);
|
|
95
96
|
const federationRules = [
|
|
96
97
|
ReservedSubgraphNameRule,
|
|
98
|
+
LinkSpecReservedTypeNamesRule,
|
|
97
99
|
KnownFederationDirectivesRule,
|
|
98
100
|
FieldSetRules,
|
|
99
101
|
InaccessibleRules,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theguild/federation-composition",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.3-alpha-20260113121415-bf20f64cd15d5043b10d499b094f1064eae2ea2f",
|
|
4
4
|
"description": "Open Source Composition library for Apollo Federation",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^16.0.0"
|
|
@@ -0,0 +1,4 @@
|
|
|
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
|
|
@@ -0,0 +1,4 @@
|
|
|
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
|