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
2 changes: 1 addition & 1 deletion controlplane/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"axios": "^1.4.0",
"cookie": "^0.5.0",
"dotenv": "^16.3.1",
"drizzle-orm": "^0.28.1",
"drizzle-orm": "^0.28.5",
"fastify": "^4.21.0",
"fastify-graceful-shutdown": "^3.5.1",
"fastify-plugin": "^4.5.1",
Expand Down
45 changes: 24 additions & 21 deletions controlplane/src/core/repositories/FederatedGraphRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,33 +258,36 @@ export class FederatedGraphRepository {
name: targets.name,
})
.from(targets)
.where(and(eq(targets.organizationId, this.organizationId), eq(targets.type, 'federated')))
.innerJoin(federatedGraphs, eq(federatedGraphs.targetId, targets.id))
.leftJoin(schemaVersion, eq(schemaVersion.id, federatedGraphs.composedSchemaVersionId))
// This is a negative lookup. We check if there is a label matchers of a federated graph
// that does not match the given subgraph labels. If all label matchers match, then the
// federated graph will be part of the result.
.where(
notExists(
this.db
.select()
.from(targetLabelMatchers)
.where(
and(
eq(targetLabelMatchers.targetId, targets.id),
not(
// We created a GIN index on the label_matcher column, so we can look up
// very quickly if the label matcher matches the given subgraph labels.
sql.raw(
`${targetLabelMatchers.labelMatcher.name} && ARRAY[${uniqueLabels.map(
(ul) => "'" + joinLabel(ul) + "'",
)}]`,
and(
eq(targets.organizationId, this.organizationId),
eq(targets.type, 'federated'),
// This is a negative lookup. We check if there is a label matchers of a federated graph
// that does not match the given subgraph labels. If all label matchers match, then the
// federated graph will be part of the result.
notExists(
this.db
.select()
.from(targetLabelMatchers)
.where(
and(
eq(targetLabelMatchers.targetId, targets.id),
not(
// We created a GIN index on the label_matcher column, so we can look up
// very quickly if the label matcher matches the given subgraph labels.
sql.raw(
`${targetLabelMatchers.labelMatcher.name} && ARRAY[${uniqueLabels.map(
(ul) => "'" + joinLabel(ul) + "'",
)}]`,
),
),
),
),
),
),
),
)
.innerJoin(federatedGraphs, eq(federatedGraphs.targetId, targets.id))
.leftJoin(schemaVersion, eq(schemaVersion.id, federatedGraphs.composedSchemaVersionId))
.orderBy(asc(targets.createdAt), asc(schemaVersion.createdAt))
.execute();

Expand Down
3 changes: 1 addition & 2 deletions controlplane/src/core/repositories/SubgraphRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,7 @@ export class SubgraphRepository {
const subgraphs = await this.db
.select({ id: schema.subgraphs.id, name: schema.targets.name })
.from(targets)
.where(and(eq(schema.targets.organizationId, this.organizationId), eq(targets.type, 'subgraph')))
.where(and(...conditions))
.where(and(eq(targets.organizationId, this.organizationId), eq(targets.type, 'subgraph'), ...conditions))
.innerJoin(schema.subgraphs, eq(schema.subgraphs.targetId, targets.id))
.execute();

Expand Down
1 change: 1 addition & 0 deletions controlplane/test/authenthication.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('Authentication', (ctx) => {
url: databaseConnectionUrl,
},
keycloak: {
loginRealm: 'test',
realm: 'test',
adminUser: 'admin',
adminPassword: 'changeme',
Expand Down
10 changes: 6 additions & 4 deletions pnpm-lock.yaml

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

2 changes: 2 additions & 0 deletions scripts/create-docker-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pnpm wgc subgraph create family --label team=A env=production --routing-url http
pnpm wgc subgraph create hobbies --label team=B env=production --routing-url http://hobbies:4003/graphql
pnpm wgc subgraph create products --label team=B env=production --routing-url http://products:4004/graphql

cd "../scripts"

./update-docker-demo.sh

pnpm wgc federated-graph create-token production --name mytoken
2 changes: 2 additions & 0 deletions scripts/create-local-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ pnpm wgc subgraph create family --label team=A env=production --routing-url http
pnpm wgc subgraph create hobbies --label team=B env=production --routing-url http://localhost:4003/graphql
pnpm wgc subgraph create products --label team=B env=production --routing-url http://localhost:4004/graphql

cd "../scripts"

./update-local-demo.sh

pnpm wgc federated-graph create-token production --name mytoken