Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,129 changes: 3,189 additions & 2,940 deletions connect-go/gen/proto/wg/cosmo/platform/v1/platform.pb.go

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,106 changes: 617 additions & 489 deletions connect/src/wg/cosmo/platform/v1/platform_pb.ts

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions controlplane/src/core/bufservices/PlatformService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ import { updateIDPMappers } from './sso/updateIDPMappers.js';
import { addReadme } from './subgraph/addReadme.js';
import { checkSubgraphSchema } from './subgraph/checkSubgraphSchema.js';
import { createFederatedSubgraph } from './subgraph/createFederatedSubgraph.js';
import { createFederatedSubgraphs } from './subgraph/createFederatedSubgraphs.js';
import { deleteFederatedSubgraph } from './subgraph/deleteFederatedSubgraph.js';
import { fixSubgraphSchema } from './subgraph/fixSubgraphSchema.js';
import { getLatestSubgraphSDL } from './subgraph/getLatestSubgraphSDL.js';
Expand Down Expand Up @@ -254,6 +255,10 @@ export default function (opts: RouterOptions): Partial<ServiceImpl<typeof Platfo
return createFederatedSubgraph(opts, req, ctx);
},

createFederatedSubgraphs: (req, ctx) => {
return createFederatedSubgraphs(opts, req, ctx);
},

checkSubgraphSchema: (req, ctx) => {
return checkSubgraphSchema(opts, req, ctx);
},
Expand Down
34 changes: 18 additions & 16 deletions controlplane/src/core/bufservices/monograph/createMonograph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,24 @@ export function createMonograph(

const labelMatchers = [joinLabel(label)];

const subgraph = await subgraphRepo.create({
name: req.name,
namespace: req.namespace,
namespaceId: namespace.id,
createdBy: authContext.userId,
labels: [label],
routingUrl: req.graphUrl,
isEventDrivenGraph: false,
readme: req.readme,
subscriptionUrl: req.subscriptionUrl,
subscriptionProtocol:
req.subscriptionProtocol === undefined ? undefined : formatSubscriptionProtocol(req.subscriptionProtocol),
websocketSubprotocol:
req.websocketSubprotocol === undefined ? undefined : formatWebsocketSubprotocol(req.websocketSubprotocol),
type: 'standard',
});
const [subgraph] = await subgraphRepo.create([
{
name: req.name,
namespace: req.namespace,
namespaceId: namespace.id,
createdBy: authContext.userId,
labels: [label],
routingUrl: req.graphUrl,
isEventDrivenGraph: false,
readme: req.readme,
subscriptionUrl: req.subscriptionUrl,
subscriptionProtocol:
req.subscriptionProtocol === undefined ? undefined : formatSubscriptionProtocol(req.subscriptionProtocol),
websocketSubprotocol:
req.websocketSubprotocol === undefined ? undefined : formatWebsocketSubprotocol(req.websocketSubprotocol),
type: 'standard',
},
]);

if (!subgraph) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,18 @@ export function validateAndFetchPluginData(
};
}

subgraph = await subgraphRepo.create({
name: req.name,
namespace: req.namespace,
namespaceId: namespace.id,
createdBy: authContext.userId,
labels: req.labels,
routingUrl: '',
isEventDrivenGraph: false,
type: 'grpc_plugin',
});
[subgraph] = await subgraphRepo.create([
{
name: req.name,
namespace: req.namespace,
namespaceId: namespace.id,
createdBy: authContext.userId,
labels: req.labels,
routingUrl: '',
isEventDrivenGraph: false,
type: 'grpc_plugin',
},
]);

if (!subgraph) {
return {
Expand Down
153 changes: 44 additions & 109 deletions controlplane/src/core/bufservices/subgraph/createFederatedSubgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
CreateFederatedSubgraphResponse,
SubgraphType,
} from '@wundergraph/cosmo-connect/dist/platform/v1/platform_pb';
import { isValidUrl } from '@wundergraph/cosmo-shared';
import { AuditLogRepository } from '../../repositories/AuditLogRepository.js';
import { DefaultNamespace, NamespaceRepository } from '../../repositories/NamespaceRepository.js';
import { SubgraphRepository } from '../../repositories/SubgraphRepository.js';
Expand All @@ -19,8 +18,8 @@ import {
getLogger,
handleError,
isValidGraphName,
isValidGrpcNamingScheme,
isValidLabels,
validateSubgraphRouting,
} from '../../util.js';
import { UnauthorizedError } from '../../errors/errors.js';
import { PluginRepository } from '../../repositories/PluginRepository.js';
Expand Down Expand Up @@ -105,91 +104,25 @@ export function createFederatedSubgraph(
* The routing URL must be defined unless the subgraph is an Event-Driven Graph or a Plugin
* */
const routingUrl = req.routingUrl || '';
if (req.isEventDrivenGraph) {
if (req.routingUrl !== undefined) {
return {
response: {
code: EnumStatusCode.ERR,
details: `An Event-Driven Graph must not define a routing URL`,
},
compositionErrors: [],
admissionErrors: [],
};
}
if (req.subscriptionUrl !== undefined) {
return {
response: {
code: EnumStatusCode.ERR,
details: `An Event-Driven Graph must not define a subscription URL`,
},
compositionErrors: [],
admissionErrors: [],
};
}
if (req.subscriptionProtocol !== undefined) {
return {
response: {
code: EnumStatusCode.ERR,
details: `An Event-Driven Graph must not define a subscription protocol`,
},
compositionErrors: [],
admissionErrors: [],
};
}
if (req.websocketSubprotocol !== undefined) {
return {
response: {
code: EnumStatusCode.ERR,
details: `An Event-Driven Graph must not define a websocket subprotocol`,
},
compositionErrors: [],
admissionErrors: [],
};
}
} else if (req.type !== SubgraphType.GRPC_PLUGIN) {
if (!routingUrl) {
return {
response: {
code: EnumStatusCode.ERR,
details: `A non-Event-Driven Graph must define a routing URL`,
},
compositionErrors: [],
admissionErrors: [],
};
}
if (!isValidUrl(routingUrl)) {
return {
response: {
code: EnumStatusCode.ERR,
details: `Routing URL "${routingUrl}" is not a valid URL`,
},
compositionErrors: [],
admissionErrors: [],
};
}
// For GRPC_SERVICE subgraphs, validate that routing URL follows gRPC naming scheme
if (req.type === SubgraphType.GRPC_SERVICE && !isValidGrpcNamingScheme(routingUrl)) {
return {
response: {
code: EnumStatusCode.ERR,
details:
`Routing URL must follow gRPC naming scheme. ` +
`See https://grpc.io/docs/guides/custom-name-resolution/ for examples.`,
},
compositionErrors: [],
admissionErrors: [],
};
}
if (req.subscriptionUrl && !isValidUrl(req.subscriptionUrl)) {
return {
response: {
code: EnumStatusCode.ERR,
details: `Subscription URL "${req.subscriptionUrl}" is not a valid URL`,
},
compositionErrors: [],
admissionErrors: [],
};
}
const routingViolation = validateSubgraphRouting({
Comment thread
JivusAyrus marked this conversation as resolved.
isEventDrivenGraph: req.isEventDrivenGraph || false,
routingUrl: req.routingUrl,
subscriptionUrl: req.subscriptionUrl,
subscriptionProtocol: req.subscriptionProtocol,
websocketSubprotocol: req.websocketSubprotocol,
routingUrlRequirement: req.type === SubgraphType.GRPC_PLUGIN ? 'skipped' : 'required',
isGrpcService: req.type === SubgraphType.GRPC_SERVICE,
});

if (routingViolation) {
return {
response: {
code: EnumStatusCode.ERR,
details: routingViolation,
},
compositionErrors: [],
admissionErrors: [],
};
}

const namespace = await namespaceRepo.byName(req.namespace);
Expand Down Expand Up @@ -250,28 +183,30 @@ export function createFederatedSubgraph(
}
}

const subgraph = await subgraphRepo.create({
name: req.name,
namespace: req.namespace,
namespaceId: namespace.id,
createdBy: authContext.userId,
labels: req.labels,
routingUrl,
isEventDrivenGraph: req.isEventDrivenGraph || false,
readme: req.readme,
subscriptionUrl: req.subscriptionUrl,
subscriptionProtocol:
req.subscriptionProtocol === undefined ? undefined : formatSubscriptionProtocol(req.subscriptionProtocol),
websocketSubprotocol:
req.websocketSubprotocol === undefined ? undefined : formatWebsocketSubprotocol(req.websocketSubprotocol),
featureSubgraphOptions: req.isFeatureSubgraph
? {
isFeatureSubgraph: req.isFeatureSubgraph || false,
baseSubgraphID,
}
: undefined,
type: formatSubgraphType(req.type),
});
const [subgraph] = await subgraphRepo.create([
{
name: req.name,
namespace: req.namespace,
namespaceId: namespace.id,
createdBy: authContext.userId,
labels: req.labels,
routingUrl,
isEventDrivenGraph: req.isEventDrivenGraph || false,
readme: req.readme,
subscriptionUrl: req.subscriptionUrl,
subscriptionProtocol:
req.subscriptionProtocol === undefined ? undefined : formatSubscriptionProtocol(req.subscriptionProtocol),
websocketSubprotocol:
req.websocketSubprotocol === undefined ? undefined : formatWebsocketSubprotocol(req.websocketSubprotocol),
featureSubgraphOptions: req.isFeatureSubgraph
? {
isFeatureSubgraph: req.isFeatureSubgraph || false,
baseSubgraphID,
}
: undefined,
type: formatSubgraphType(req.type),
},
]);

if (!subgraph) {
return {
Expand Down
Loading
Loading