Skip to content
5 changes: 3 additions & 2 deletions cli/src/commands/router/commands/compose.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ export default (opts: BaseCommandOptions) => {
'--disable-resolvability-validation',
'This flag will disable the validation for whether all nodes of the federated graph are resolvable. Do NOT use unless troubleshooting.',
);
command.option('--ignore-external-keys', 'This flag ignores errors related to true external entity keys.');

command.action(async (options) => {
const inputFile = resolve(options.input);
Expand Down Expand Up @@ -208,7 +209,7 @@ export default (opts: BaseCommandOptions) => {
};
}),
{
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys: options.ignoreExternalKeys,
disableResolvabilityValidation: options.disableResolvabilityValidation,
},
);
Expand Down Expand Up @@ -591,7 +592,7 @@ async function buildFeatureFlagsConfig(
definitions: parse(s.sdl),
})),
{
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys: options.ignoreExternalKeys,
disableResolvabilityValidation: options.disableResolvabilityValidation,
},
);
Expand Down
7 changes: 6 additions & 1 deletion controlplane/src/core/bufservices/contract/createContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
DeploymentError,
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { isValidUrl } from '@wundergraph/cosmo-shared';
import { COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID } from '../../../types/index.js';
import { PublicError, UnauthorizedError } from '../../errors/errors.js';
import { AuditLogRepository } from '../../repositories/AuditLogRepository.js';
import { ContractRepository } from '../../repositories/ContractRepository.js';
Expand Down Expand Up @@ -104,6 +105,10 @@ export function createContract(
organizationId: authContext.organizationId,
featureId: 'federated-graphs',
});
const ignoreExternalKeysFeature = await orgRepo.getFeature({
organizationId: authContext.organizationId,
featureId: COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID,
});

const limit = feature?.limit === -1 ? undefined : feature?.limit;

Expand Down Expand Up @@ -198,7 +203,7 @@ export function createContract(
blobStorage: opts.blobStorage,
chClient: opts.chClient!,
compositionOptions: {
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys: ignoreExternalKeysFeature?.enabled ?? false,
disableResolvabilityValidation: req.disableResolvabilityValidation,
},
federatedGraphs: [{ ...contractGraph, contract }],
Expand Down
15 changes: 13 additions & 2 deletions controlplane/src/core/bufservices/contract/updateContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import {
UpdateContractRequest,
UpdateContractResponse,
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID } from '../../../types/index.js';
import { AuditLogRepository } from '../../repositories/AuditLogRepository.js';
import { ContractRepository } from '../../repositories/ContractRepository.js';
import { FederatedGraphRepository } from '../../repositories/FederatedGraphRepository.js';
import { DefaultNamespace } from '../../repositories/NamespaceRepository.js';
import { OrganizationRepository } from '../../repositories/OrganizationRepository.js';
import type { RouterOptions } from '../../routes.js';
import { enrichLogger, getLogger, handleError, isValidSchemaTags } from '../../util.js';
import { OrganizationWebhookService } from '../../webhooks/OrganizationWebhookService.js';
Expand All @@ -33,6 +35,7 @@ export function updateContract(

const fedGraphRepo = new FederatedGraphRepository(logger, opts.db, authContext.organizationId);
const contractRepo = new ContractRepository(logger, opts.db, authContext.organizationId);
const orgRepo = new OrganizationRepository(logger, opts.db, opts.billingDefaultPlanId);
const auditLogRepo = new AuditLogRepository(opts.db);
const orgWebhooks = new OrganizationWebhookService(
opts.db,
Expand Down Expand Up @@ -116,6 +119,14 @@ export function updateContract(
};
}

const ignoreExternalKeys =
(
await orgRepo.getFeature({
organizationId: authContext.organizationId,
featureId: COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID,
})
)?.enabled ?? false;

const updatedContractDetails = await contractRepo.update({
id: graph.contract.id,
excludeTags: req.excludeTags,
Expand All @@ -141,7 +152,7 @@ export function updateContract(
labelMatchers: [],
chClient: opts.chClient!,
compositionOptions: {
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys,
disableResolvabilityValidation: req.disableResolvabilityValidation,
},
});
Expand All @@ -159,7 +170,7 @@ export function updateContract(
blobStorage: opts.blobStorage,
chClient: opts.chClient!,
compositionOptions: {
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys,
disableResolvabilityValidation: req.disableResolvabilityValidation,
},
federatedGraphs: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
CreateFeatureFlagResponse,
DeploymentError,
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID } from '../../../types/index.js';
import { AuditLogRepository } from '../../repositories/AuditLogRepository.js';
import { FeatureFlagRepository } from '../../repositories/FeatureFlagRepository.js';
import { FederatedGraphRepository } from '../../repositories/FederatedGraphRepository.js';
Expand Down Expand Up @@ -189,6 +190,10 @@ export function createFeatureFlag(
namespaceId: namespace.id,
excludeDisabled: true,
});
const ignoreExternalKeysFeature = await orgRepo.getFeature({
organizationId: authContext.organizationId,
featureId: COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID,
});

const compositionErrors: PlainMessage<CompositionError>[] = [];
const deploymentErrors: PlainMessage<DeploymentError>[] = [];
Expand All @@ -206,7 +211,7 @@ export function createFeatureFlag(
blobStorage: opts.blobStorage,
chClient: opts.chClient!,
compositionOptions: {
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys: ignoreExternalKeysFeature?.enabled ?? false,
disableResolvabilityValidation: req.disableResolvabilityValidation,
},
federatedGraphs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import {
DeleteFeatureFlagResponse,
DeploymentError,
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID } from '../../../types/index.js';
import { AuditLogRepository } from '../../repositories/AuditLogRepository.js';
import { FeatureFlagRepository } from '../../repositories/FeatureFlagRepository.js';
import { FederatedGraphRepository } from '../../repositories/FederatedGraphRepository.js';
import { DefaultNamespace, NamespaceRepository } from '../../repositories/NamespaceRepository.js';
import { OrganizationRepository } from '../../repositories/OrganizationRepository.js';
import type { RouterOptions } from '../../routes.js';
import { enrichLogger, getLogger, handleError } from '../../util.js';
import { OrganizationWebhookService } from '../../webhooks/OrganizationWebhookService.js';
Expand All @@ -31,6 +33,7 @@ export function deleteFeatureFlag(

const featureFlagRepo = new FeatureFlagRepository(logger, opts.db, authContext.organizationId);
const namespaceRepo = new NamespaceRepository(opts.db, authContext.organizationId);
const orgRepo = new OrganizationRepository(logger, opts.db, opts.billingDefaultPlanId);
const orgWebhooks = new OrganizationWebhookService(
opts.db,
authContext.organizationId,
Expand Down Expand Up @@ -102,6 +105,11 @@ export function deleteFeatureFlag(
});
}

const ignoreExternalKeysFeature = await orgRepo.getFeature({
organizationId: authContext.organizationId,
featureId: COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID,
});

const compositionErrors: PlainMessage<CompositionError>[] = [];
const deploymentErrors: PlainMessage<DeploymentError>[] = [];
const compositionWarnings: PlainMessage<CompositionWarning>[] = [];
Expand Down Expand Up @@ -136,7 +144,7 @@ export function deleteFeatureFlag(
blobStorage: opts.blobStorage,
chClient: opts.chClient!,
compositionOptions: {
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys: ignoreExternalKeysFeature?.enabled ?? false,
disableResolvabilityValidation: req.disableResolvabilityValidation,
},
federatedGraphs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import {
EnableFeatureFlagRequest,
EnableFeatureFlagResponse,
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID } from '../../../types/index.js';
import { AuditLogRepository } from '../../repositories/AuditLogRepository.js';
import { FeatureFlagRepository } from '../../repositories/FeatureFlagRepository.js';
import { FederatedGraphRepository } from '../../repositories/FederatedGraphRepository.js';
import { DefaultNamespace, NamespaceRepository } from '../../repositories/NamespaceRepository.js';
import { OrganizationRepository } from '../../repositories/OrganizationRepository.js';
import type { RouterOptions } from '../../routes.js';
import { enrichLogger, getLogger, handleError } from '../../util.js';
import { OrganizationWebhookService } from '../../webhooks/OrganizationWebhookService.js';
Expand All @@ -31,6 +33,7 @@ export function enableFeatureFlag(

const featureFlagRepo = new FeatureFlagRepository(logger, opts.db, authContext.organizationId);
const namespaceRepo = new NamespaceRepository(opts.db, authContext.organizationId);
const orgRepo = new OrganizationRepository(logger, opts.db, opts.billingDefaultPlanId);
const auditLogRepo = new AuditLogRepository(opts.db);
const orgWebhooks = new OrganizationWebhookService(
opts.db,
Expand Down Expand Up @@ -103,6 +106,10 @@ export function enableFeatureFlag(
// fetch the federated graphs based on the state that has just been set for the feature flag above
excludeDisabled: req.enabled,
});
const ignoreExternalKeysFeature = await orgRepo.getFeature({
organizationId: authContext.organizationId,
featureId: COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID,
});

const compositionErrors: PlainMessage<CompositionError>[] = [];
const deploymentErrors: PlainMessage<DeploymentError>[] = [];
Expand All @@ -120,7 +127,7 @@ export function enableFeatureFlag(
blobStorage: opts.blobStorage,
chClient: opts.chClient!,
compositionOptions: {
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys: ignoreExternalKeysFeature?.enabled ?? false,
disableResolvabilityValidation: req.disableResolvabilityValidation,
},
federatedGraphs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import {
UpdateFeatureFlagRequest,
UpdateFeatureFlagResponse,
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { FederatedGraphDTO } from '../../../types/index.js';
import { COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID, FederatedGraphDTO } from '../../../types/index.js';
import { AuditLogRepository } from '../../repositories/AuditLogRepository.js';
import { FeatureFlagRepository } from '../../repositories/FeatureFlagRepository.js';
import { FederatedGraphRepository } from '../../repositories/FederatedGraphRepository.js';
import { DefaultNamespace, NamespaceRepository } from '../../repositories/NamespaceRepository.js';
import { OrganizationRepository } from '../../repositories/OrganizationRepository.js';
import type { RouterOptions } from '../../routes.js';
import { enrichLogger, getLogger, handleError, isValidLabels } from '../../util.js';
import { OrganizationWebhookService } from '../../webhooks/OrganizationWebhookService.js';
Expand All @@ -32,6 +33,7 @@ export function updateFeatureFlag(

const featureFlagRepo = new FeatureFlagRepository(logger, opts.db, authContext.organizationId);
const namespaceRepo = new NamespaceRepository(opts.db, authContext.organizationId);
const orgRepo = new OrganizationRepository(logger, opts.db, opts.billingDefaultPlanId);
const orgWebhooks = new OrganizationWebhookService(
opts.db,
authContext.organizationId,
Expand Down Expand Up @@ -159,6 +161,11 @@ export function updateFeatureFlag(
allFederatedGraphsToCompose.push(newFederatedGraph);
}

const ignoreExternalKeysFeature = await orgRepo.getFeature({
organizationId: authContext.organizationId,
featureId: COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID,
});

const compositionErrors: PlainMessage<CompositionError>[] = [];
const deploymentErrors: PlainMessage<DeploymentError>[] = [];
const compositionWarnings: PlainMessage<CompositionWarning>[] = [];
Expand All @@ -175,7 +182,7 @@ export function updateFeatureFlag(
blobStorage: opts.blobStorage,
chClient: opts.chClient!,
compositionOptions: {
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys: ignoreExternalKeysFeature?.enabled ?? false,
disableResolvabilityValidation: req.disableResolvabilityValidation,
},
federatedGraphs: allFederatedGraphsToCompose,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import {
Subgraph,
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { parse } from 'graphql';
import { COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID } from '../../../types/index.js';
import { composeSubgraphs } from '../../composition/composition.js';
import { FederatedGraphRepository } from '../../repositories/FederatedGraphRepository.js';
import { DefaultNamespace } from '../../repositories/NamespaceRepository.js';
import { OrganizationRepository } from '../../repositories/OrganizationRepository.js';
import { SubgraphRepository } from '../../repositories/SubgraphRepository.js';
import type { RouterOptions } from '../../routes.js';
import {
Expand All @@ -38,6 +40,7 @@ export function checkFederatedGraph(

const fedGraphRepo = new FederatedGraphRepository(logger, opts.db, authContext.organizationId);
const subgraphRepo = new SubgraphRepository(logger, opts.db, authContext.organizationId);
const orgRepo = new OrganizationRepository(logger, opts.db, opts.billingDefaultPlanId);

req.namespace = req.namespace || DefaultNamespace;

Expand Down Expand Up @@ -100,6 +103,11 @@ export function checkFederatedGraph(
type: convertToSubgraphType(s.type),
}));

const ignoreExternalKeysFeature = await orgRepo.getFeature({
organizationId: authContext.organizationId,
featureId: COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID,
});

const result = composeSubgraphs(
subgraphsUsedForComposition.map((s) => ({
id: s.id,
Expand All @@ -109,7 +117,7 @@ export function checkFederatedGraph(
})),
federatedGraph.routerCompatibilityVersion,
{
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys: ignoreExternalKeysFeature?.enabled ?? false,
disableResolvabilityValidation: req.disableResolvabilityValidation,
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
DeploymentError,
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { isValidUrl } from '@wundergraph/cosmo-shared';
import { COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID } from '../../../types/index.js';
import { AuditLogRepository } from '../../repositories/AuditLogRepository.js';
import { FederatedGraphRepository } from '../../repositories/FederatedGraphRepository.js';
import { DefaultNamespace, NamespaceRepository } from '../../repositories/NamespaceRepository.js';
Expand Down Expand Up @@ -210,6 +211,11 @@ export function createFederatedGraph(
};
}

const ignoreExternalKeysFeature = await orgRepo.getFeature({
organizationId: authContext.organizationId,
featureId: COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID,
});

const compositionErrors: PlainMessage<CompositionError>[] = [];
const deploymentErrors: PlainMessage<DeploymentError>[] = [];
const compositionWarnings: PlainMessage<CompositionWarning>[] = [];
Expand All @@ -226,7 +232,7 @@ export function createFederatedGraph(
blobStorage: opts.blobStorage,
chClient: opts.chClient!,
compositionOptions: {
// @TODO ignoreExternalKeys: ?,
ignoreExternalKeys: ignoreExternalKeysFeature?.enabled ?? false,
disableResolvabilityValidation: req.disableResolvabilityValidation,
},
federatedGraphs: [federatedGraph],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
MigrateFromApolloRequest,
MigrateFromApolloResponse,
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { GraphApiKeyJwtPayload } from '../../../types/index.js';
import { COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID, GraphApiKeyJwtPayload } from '../../../types/index.js';
import { audiences, signJwtHS256 } from '../../crypto/jwt.js';
import { AuditLogRepository } from '../../repositories/AuditLogRepository.js';
import { FederatedGraphRepository } from '../../repositories/FederatedGraphRepository.js';
Expand Down Expand Up @@ -131,6 +131,11 @@ export function migrateFromApollo(
}
}

const ignoreExternalKeysFeature = await orgRepo.getFeature({
organizationId: authContext.organizationId,
featureId: COMPOSITION_IGNORE_EXTERNAL_KEYS_FEATURE_ID,
});

await opts.db.transaction(async (tx) => {
const fedGraphRepo = new FederatedGraphRepository(logger, tx, authContext.organizationId);

Expand All @@ -157,6 +162,7 @@ export function migrateFromApollo(
},
chClient: opts.chClient!,
compositionOptions: {
ignoreExternalKeys: ignoreExternalKeysFeature?.enabled ?? false,
disableResolvabilityValidation: true,
},
});
Expand Down
Loading
Loading