Skip to content

Commit e50ed60

Browse files
committed
feat(app): unify schema composition settings mutations
1 parent d1ec149 commit e50ed60

File tree

17 files changed

+419
-551
lines changed

17 files changed

+419
-551
lines changed

integration-tests/testkit/flow.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import type {
1212
CreateTokenInput,
1313
DeleteMemberRoleInput,
1414
DeleteTokensInput,
15-
EnableExternalSchemaCompositionInput,
1615
Experimental__UpdateTargetSchemaCompositionInput,
1716
InviteToOrganizationByEmailInput,
1817
OrganizationSelectorInput,
@@ -27,6 +26,7 @@ import type {
2726
UpdateMemberRoleInput,
2827
UpdateOrganizationSlugInput,
2928
UpdateProjectSlugInput,
29+
UpdateSchemaCompositionInput,
3030
UpdateTargetConditionalBreakingChangeConfigurationInput,
3131
UpdateTargetSlugInput,
3232
} from './gql/graphql';
@@ -1508,25 +1508,24 @@ export async function updateOrgRateLimit(
15081508
});
15091509
}
15101510

1511-
export async function enableExternalSchemaComposition(
1512-
input: EnableExternalSchemaCompositionInput,
1513-
token: string,
1514-
) {
1511+
export async function updateSchemaComposition(input: UpdateSchemaCompositionInput, token: string) {
15151512
return execute({
15161513
document: graphql(`
1517-
mutation enableExternalSchemaComposition($input: EnableExternalSchemaCompositionInput!) {
1518-
enableExternalSchemaComposition(input: $input) {
1514+
mutation updateSchemaComposition($input: UpdateSchemaCompositionInput!) {
1515+
updateSchemaComposition(input: $input) {
15191516
ok {
15201517
id
15211518
externalSchemaComposition {
15221519
endpoint
15231520
}
15241521
}
15251522
error {
1526-
message
1527-
inputErrors {
1528-
endpoint
1529-
secret
1523+
... on UpdateSchemaCompositionExternalError {
1524+
message
1525+
inputErrors {
1526+
endpoint
1527+
secret
1528+
}
15301529
}
15311530
}
15321531
}

integration-tests/tests/api/schema/composition-federation-2.spec.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ProjectType } from 'testkit/gql/graphql';
2-
import { enableExternalSchemaComposition } from '../../../testkit/flow';
2+
import { updateSchemaComposition } from '../../../testkit/flow';
33
import { initSeed } from '../../../testkit/seed';
44
import { generateUnique, getServiceHost } from '../../../testkit/utils';
55

@@ -38,19 +38,20 @@ test.concurrent('call an external service to compose and validate services', asy
3838
expect(publishUsersResult.schemaPublish.__typename).toBe('SchemaPublishSuccess');
3939

4040
// enable external composition
41-
const externalCompositionResult = await enableExternalSchemaComposition(
41+
const externalCompositionResult = await updateSchemaComposition(
4242
{
43-
endpoint: `http://${dockerAddress}/compose`,
44-
// eslint-disable-next-line no-process-env
45-
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
46-
projectSlug: project.slug,
47-
organizationSlug: organization.slug,
43+
external: {
44+
endpoint: `http://${dockerAddress}/compose`,
45+
// eslint-disable-next-line no-process-env
46+
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
47+
projectSlug: project.slug,
48+
organizationSlug: organization.slug,
49+
},
4850
},
4951
ownerToken,
5052
).then(r => r.expectNoGraphQLErrors());
5153
expect(
52-
externalCompositionResult.enableExternalSchemaComposition.ok?.externalSchemaComposition
53-
?.endpoint,
54+
externalCompositionResult.updateSchemaComposition.ok?.externalSchemaComposition?.endpoint,
5455
).toBe(`http://${dockerAddress}/compose`);
5556
// Disable Native Federation v2 composition to allow the external composition to take place
5657
await setNativeFederation(false);

integration-tests/tests/api/schema/delete.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import 'reflect-metadata';
22
import { parse, print } from 'graphql';
3-
import { enableExternalSchemaComposition } from 'testkit/flow';
3+
import { updateSchemaComposition } from 'testkit/flow';
44
import { ProjectType } from 'testkit/gql/graphql';
55
import { initSeed } from 'testkit/seed';
66
import { getServiceHost } from 'testkit/utils';
@@ -235,13 +235,15 @@ test.concurrent(
235235

236236
const readToken = await createTargetAccessToken({});
237237

238-
await enableExternalSchemaComposition(
238+
await updateSchemaComposition(
239239
{
240-
endpoint: `http://${await getServiceHost('composition_federation_2', 3069, false)}/compose`,
241-
// eslint-disable-next-line no-process-env
242-
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
243-
projectSlug: project.slug,
244-
organizationSlug: organization.slug,
240+
external: {
241+
endpoint: `http://${await getServiceHost('composition_federation_2', 3069, false)}/compose`,
242+
// eslint-disable-next-line no-process-env
243+
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
244+
projectSlug: project.slug,
245+
organizationSlug: organization.slug,
246+
},
245247
},
246248
ownerToken,
247249
).then(r => r.expectNoGraphQLErrors());

integration-tests/tests/api/schema/external-composition.spec.ts

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ProjectType } from 'testkit/gql/graphql';
22
import { history } from '../../../testkit/external-composition';
3-
import { enableExternalSchemaComposition } from '../../../testkit/flow';
3+
import { updateSchemaComposition } from '../../../testkit/flow';
44
import { initSeed } from '../../../testkit/seed';
55
import { generateUnique, getServiceHost } from '../../../testkit/utils';
66

@@ -43,19 +43,20 @@ test.concurrent('call an external service to compose and validate services', asy
4343
// so we need to use the name and not resolved host
4444
const dockerAddress = await getServiceHost('external_composition', 3012, false);
4545
// enable external composition
46-
const externalCompositionResult = await enableExternalSchemaComposition(
46+
const externalCompositionResult = await updateSchemaComposition(
4747
{
48-
endpoint: `http://${dockerAddress}/compose`,
49-
// eslint-disable-next-line no-process-env
50-
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
51-
projectSlug: project.slug,
52-
organizationSlug: organization.slug,
48+
external: {
49+
endpoint: `http://${dockerAddress}/compose`,
50+
// eslint-disable-next-line no-process-env
51+
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
52+
projectSlug: project.slug,
53+
organizationSlug: organization.slug,
54+
},
5355
},
5456
ownerToken,
5557
).then(r => r.expectNoGraphQLErrors());
5658
expect(
57-
externalCompositionResult.enableExternalSchemaComposition.ok?.externalSchemaComposition
58-
?.endpoint,
59+
externalCompositionResult.updateSchemaComposition.ok?.externalSchemaComposition?.endpoint,
5960
).toBe(`http://${dockerAddress}/compose`);
6061

6162
// set native federation to false to force external composition
@@ -126,19 +127,20 @@ test.concurrent(
126127
// so we need to use the name and not resolved host
127128
const dockerAddress = await getServiceHost('external_composition', 3012, false);
128129
// enable external composition
129-
const externalCompositionResult = await enableExternalSchemaComposition(
130+
const externalCompositionResult = await updateSchemaComposition(
130131
{
131-
endpoint: `http://${dockerAddress}/fail_on_signature`,
132-
// eslint-disable-next-line no-process-env
133-
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
134-
projectSlug: project.slug,
135-
organizationSlug: organization.slug,
132+
external: {
133+
endpoint: `http://${dockerAddress}/fail_on_signature`,
134+
// eslint-disable-next-line no-process-env
135+
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
136+
projectSlug: project.slug,
137+
organizationSlug: organization.slug,
138+
},
136139
},
137140
ownerToken,
138141
).then(r => r.expectNoGraphQLErrors());
139142
expect(
140-
externalCompositionResult.enableExternalSchemaComposition.ok?.externalSchemaComposition
141-
?.endpoint,
143+
externalCompositionResult.updateSchemaComposition.ok?.externalSchemaComposition?.endpoint,
142144
).toBe(`http://${dockerAddress}/fail_on_signature`);
143145

144146
// set native federation to false to force external composition
@@ -225,19 +227,20 @@ test.concurrent(
225227
// so we need to use the name and not resolved host
226228
const dockerAddress = await getServiceHost('external_composition', 3012, false);
227229
// enable external composition
228-
const externalCompositionResult = await enableExternalSchemaComposition(
230+
const externalCompositionResult = await updateSchemaComposition(
229231
{
230-
endpoint: `http://${dockerAddress}/non-existing-endpoint`,
231-
// eslint-disable-next-line no-process-env
232-
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
233-
projectSlug: project.slug,
234-
organizationSlug: organization.slug,
232+
external: {
233+
endpoint: `http://${dockerAddress}/non-existing-endpoint`,
234+
// eslint-disable-next-line no-process-env
235+
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
236+
projectSlug: project.slug,
237+
organizationSlug: organization.slug,
238+
},
235239
},
236240
ownerToken,
237241
).then(r => r.expectNoGraphQLErrors());
238242
expect(
239-
externalCompositionResult.enableExternalSchemaComposition.ok?.externalSchemaComposition
240-
?.endpoint,
243+
externalCompositionResult.updateSchemaComposition.ok?.externalSchemaComposition?.endpoint,
241244
).toBe(`http://${dockerAddress}/non-existing-endpoint`);
242245
// set native federation to false to force external composition
243246
await setNativeFederation(false);
@@ -321,19 +324,20 @@ test.concurrent('a timeout error should be visible to the user', async ({ expect
321324
// so we need to use the name and not resolved host
322325
const dockerAddress = await getServiceHost('external_composition', 3012, false);
323326
// enable external composition
324-
const externalCompositionResult = await enableExternalSchemaComposition(
327+
const externalCompositionResult = await updateSchemaComposition(
325328
{
326-
endpoint: `http://${dockerAddress}/timeout`,
327-
// eslint-disable-next-line no-process-env
328-
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
329-
projectSlug: project.slug,
330-
organizationSlug: organization.slug,
329+
external: {
330+
endpoint: `http://${dockerAddress}/timeout`,
331+
// eslint-disable-next-line no-process-env
332+
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
333+
projectSlug: project.slug,
334+
organizationSlug: organization.slug,
335+
},
331336
},
332337
ownerToken,
333338
).then(r => r.expectNoGraphQLErrors());
334339
expect(
335-
externalCompositionResult.enableExternalSchemaComposition.ok?.externalSchemaComposition
336-
?.endpoint,
340+
externalCompositionResult.updateSchemaComposition.ok?.externalSchemaComposition?.endpoint,
337341
).toBe(`http://${dockerAddress}/timeout`);
338342
// set native federation to false to force external composition
339343
await setNativeFederation(false);

integration-tests/tests/api/schema/publish.spec.ts

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@ import { execute } from 'testkit/graphql';
77
import { getServiceHost } from 'testkit/utils';
88
// eslint-disable-next-line import/no-extraneous-dependencies
99
import { createStorage } from '@hive/storage';
10-
import {
11-
createTarget,
12-
enableExternalSchemaComposition,
13-
publishSchema,
14-
} from '../../../testkit/flow';
10+
import { createTarget, publishSchema, updateSchemaComposition } from '../../../testkit/flow';
1511
import { initSeed } from '../../../testkit/seed';
1612

1713
test.concurrent(
@@ -2804,13 +2800,15 @@ test('Composition Error (Federation 2) can be served from the database', async (
28042800
);
28052801
const readWriteToken = await createTargetAccessToken({});
28062802

2807-
await enableExternalSchemaComposition(
2803+
await updateSchemaComposition(
28082804
{
2809-
endpoint: `http://${serviceAddress}/compose`,
2810-
// eslint-disable-next-line no-process-env
2811-
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
2812-
projectSlug: project.slug,
2813-
organizationSlug: organization.slug,
2805+
external: {
2806+
endpoint: `http://${serviceAddress}/compose`,
2807+
// eslint-disable-next-line no-process-env
2808+
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
2809+
projectSlug: project.slug,
2810+
organizationSlug: organization.slug,
2811+
},
28142812
},
28152813
ownerToken,
28162814
).then(r => r.expectNoGraphQLErrors());
@@ -2924,13 +2922,15 @@ test('Composition Network Failure (Federation 2)', async () => {
29242922
);
29252923
const readWriteToken = await createTargetAccessToken({});
29262924

2927-
await enableExternalSchemaComposition(
2925+
await updateSchemaComposition(
29282926
{
2929-
endpoint: `http://${serviceAddress}/compose`,
2930-
// eslint-disable-next-line no-process-env
2931-
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
2932-
projectSlug: project.slug,
2933-
organizationSlug: organization.slug,
2927+
external: {
2928+
endpoint: `http://${serviceAddress}/compose`,
2929+
// eslint-disable-next-line no-process-env
2930+
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
2931+
projectSlug: project.slug,
2932+
organizationSlug: organization.slug,
2933+
},
29342934
},
29352935
ownerToken,
29362936
).then(r => r.expectNoGraphQLErrors());
@@ -2965,12 +2965,14 @@ test('Composition Network Failure (Federation 2)', async () => {
29652965
return;
29662966
}
29672967

2968-
await enableExternalSchemaComposition(
2968+
await updateSchemaComposition(
29692969
{
2970-
endpoint: `http://${serviceAddress}/no_compose`,
2971-
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
2972-
projectSlug: project.slug,
2973-
organizationSlug: organization.slug,
2970+
external: {
2971+
endpoint: `http://${serviceAddress}/no_compose`,
2972+
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
2973+
projectSlug: project.slug,
2974+
organizationSlug: organization.slug,
2975+
},
29742976
},
29752977
ownerToken,
29762978
).then(r => r.expectNoGraphQLErrors());

0 commit comments

Comments
 (0)