Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/wincloud_gateway/node_modules/@apollo/federation/dist/composition/validate/sdl/ drwxr-xr-x | |
| Viewing file: Select action/file-type: "use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UniqueFieldDefinitionNames = exports.existedFieldDefinitionNameMessage = exports.duplicateFieldDefinitionNameMessage = void 0;
const graphql_1 = require("graphql");
const utils_1 = require("../../utils");
function duplicateFieldDefinitionNameMessage(typeName, fieldName) {
return `Field "${typeName}.${fieldName}" can only be defined once.`;
}
exports.duplicateFieldDefinitionNameMessage = duplicateFieldDefinitionNameMessage;
function existedFieldDefinitionNameMessage(typeName, fieldName, serviceName) {
return `${utils_1.logServiceAndType(serviceName, typeName, fieldName)}Field "${typeName}.${fieldName}" already exists in the schema. It cannot also be defined in this type extension. If this is meant to be an external field, add the \`@external\` directive.`;
}
exports.existedFieldDefinitionNameMessage = existedFieldDefinitionNameMessage;
function UniqueFieldDefinitionNames(context) {
const schema = context.getSchema();
const existingTypeMap = schema
? schema.getTypeMap()
: Object.create(null);
const knownFieldNames = Object.create(null);
const possibleValueTypes = Object.create(null);
return {
InputObjectTypeExtension: checkFieldUniqueness,
InterfaceTypeExtension: checkFieldUniqueness,
ObjectTypeExtension: checkFieldUniqueness,
InputObjectTypeDefinition: checkFieldUniquenessExcludingValueTypes,
InterfaceTypeDefinition: checkFieldUniquenessExcludingValueTypes,
ObjectTypeDefinition: checkFieldUniquenessExcludingValueTypes,
};
function checkFieldUniqueness(node) {
const typeName = node.name.value;
if (!knownFieldNames[typeName]) {
knownFieldNames[typeName] = Object.create(null);
}
if (!node.fields) {
return false;
}
const fieldNames = knownFieldNames[typeName];
for (const fieldDef of node.fields) {
const fieldName = fieldDef.name.value;
if (hasField(existingTypeMap[typeName], fieldName)) {
context.reportError(new graphql_1.GraphQLError(existedFieldDefinitionNameMessage(typeName, fieldName, existingTypeMap[typeName].astNode.serviceName), fieldDef.name));
}
else if (fieldNames[fieldName]) {
context.reportError(new graphql_1.GraphQLError(duplicateFieldDefinitionNameMessage(typeName, fieldName), [fieldNames[fieldName], fieldDef.name]));
}
else {
fieldNames[fieldName] = fieldDef.name;
}
}
return false;
}
function checkFieldUniquenessExcludingValueTypes(node) {
const typeName = node.name.value;
const valueTypeFromSchema = existingTypeMap[typeName] &&
existingTypeMap[typeName].astNode;
const duplicateTypeNode = valueTypeFromSchema || possibleValueTypes[node.name.value];
if (duplicateTypeNode) {
const { fields, inputValues } = utils_1.diffTypeNodes(node, duplicateTypeNode);
if (Object.values(fields).every(diffEntry => diffEntry.length === 2)) {
return false;
}
const inputValuesTypes = Object.values(inputValues);
if (inputValuesTypes.length > 0 &&
inputValuesTypes.every((diffEntry) => diffEntry.length === 2)) {
return false;
}
}
else {
possibleValueTypes[node.name.value] = node;
}
if (!knownFieldNames[typeName]) {
knownFieldNames[typeName] = Object.create(null);
}
if (!node.fields) {
return false;
}
const fieldNames = knownFieldNames[typeName];
for (const fieldDef of node.fields) {
const fieldName = fieldDef.name.value;
if (hasField(existingTypeMap[typeName], fieldName)) {
context.reportError(new graphql_1.GraphQLError(existedFieldDefinitionNameMessage(typeName, fieldName, existingTypeMap[typeName].astNode.serviceName), fieldDef.name));
}
else if (fieldNames[fieldName]) {
context.reportError(new graphql_1.GraphQLError(duplicateFieldDefinitionNameMessage(typeName, fieldName), [fieldNames[fieldName], fieldDef.name]));
}
else {
fieldNames[fieldName] = fieldDef.name;
}
}
return false;
}
}
exports.UniqueFieldDefinitionNames = UniqueFieldDefinitionNames;
function hasField(type, fieldName) {
if (graphql_1.isObjectType(type) || graphql_1.isInterfaceType(type) || graphql_1.isInputObjectType(type)) {
return Boolean(type.getFields()[fieldName]);
}
return false;
}
//# sourceMappingURL=uniqueFieldDefinitionNames.js.map |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0037 ]-- |