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
21 changes: 10 additions & 11 deletions integration-tests/testkit/flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type {
CreateTokenInput,
DeleteMemberRoleInput,
DeleteTokensInput,
EnableExternalSchemaCompositionInput,
Experimental__UpdateTargetSchemaCompositionInput,
InviteToOrganizationByEmailInput,
OrganizationSelectorInput,
Expand All @@ -27,6 +26,7 @@ import type {
UpdateMemberRoleInput,
UpdateOrganizationSlugInput,
UpdateProjectSlugInput,
UpdateSchemaCompositionInput,
UpdateTargetConditionalBreakingChangeConfigurationInput,
UpdateTargetSlugInput,
} from './gql/graphql';
Expand Down Expand Up @@ -1508,25 +1508,24 @@ export async function updateOrgRateLimit(
});
}

export async function enableExternalSchemaComposition(
input: EnableExternalSchemaCompositionInput,
token: string,
) {
export async function updateSchemaComposition(input: UpdateSchemaCompositionInput, token: string) {
return execute({
document: graphql(`
mutation enableExternalSchemaComposition($input: EnableExternalSchemaCompositionInput!) {
enableExternalSchemaComposition(input: $input) {
mutation updateSchemaComposition($input: UpdateSchemaCompositionInput!) {
updateSchemaComposition(input: $input) {
ok {
id
externalSchemaComposition {
endpoint
}
}
error {
message
inputErrors {
endpoint
secret
... on UpdateSchemaCompositionExternalError {
message
inputErrors {
endpoint
secret
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ProjectType } from 'testkit/gql/graphql';
import { enableExternalSchemaComposition } from '../../../testkit/flow';
import { updateSchemaComposition } from '../../../testkit/flow';
import { initSeed } from '../../../testkit/seed';
import { generateUnique, getServiceHost } from '../../../testkit/utils';

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

// enable external composition
const externalCompositionResult = await enableExternalSchemaComposition(
const externalCompositionResult = await updateSchemaComposition(
{
endpoint: `http://${dockerAddress}/compose`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
external: {
endpoint: `http://${dockerAddress}/compose`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
},
},
ownerToken,
).then(r => r.expectNoGraphQLErrors());
expect(
externalCompositionResult.enableExternalSchemaComposition.ok?.externalSchemaComposition
?.endpoint,
externalCompositionResult.updateSchemaComposition.ok?.externalSchemaComposition?.endpoint,
).toBe(`http://${dockerAddress}/compose`);
// Disable Native Federation v2 composition to allow the external composition to take place
await setNativeFederation(false);
Expand Down
16 changes: 9 additions & 7 deletions integration-tests/tests/api/schema/delete.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'reflect-metadata';
import { parse, print } from 'graphql';
import { enableExternalSchemaComposition } from 'testkit/flow';
import { updateSchemaComposition } from 'testkit/flow';
import { ProjectType } from 'testkit/gql/graphql';
import { initSeed } from 'testkit/seed';
import { getServiceHost } from 'testkit/utils';
Expand Down Expand Up @@ -235,13 +235,15 @@ test.concurrent(

const readToken = await createTargetAccessToken({});

await enableExternalSchemaComposition(
await updateSchemaComposition(
{
endpoint: `http://${await getServiceHost('composition_federation_2', 3069, false)}/compose`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
external: {
endpoint: `http://${await getServiceHost('composition_federation_2', 3069, false)}/compose`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
},
},
ownerToken,
).then(r => r.expectNoGraphQLErrors());
Expand Down
70 changes: 37 additions & 33 deletions integration-tests/tests/api/schema/external-composition.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ProjectType } from 'testkit/gql/graphql';
import { history } from '../../../testkit/external-composition';
import { enableExternalSchemaComposition } from '../../../testkit/flow';
import { updateSchemaComposition } from '../../../testkit/flow';
import { initSeed } from '../../../testkit/seed';
import { generateUnique, getServiceHost } from '../../../testkit/utils';

Expand Down Expand Up @@ -43,19 +43,20 @@ test.concurrent('call an external service to compose and validate services', asy
// so we need to use the name and not resolved host
const dockerAddress = await getServiceHost('external_composition', 3012, false);
// enable external composition
const externalCompositionResult = await enableExternalSchemaComposition(
const externalCompositionResult = await updateSchemaComposition(
{
endpoint: `http://${dockerAddress}/compose`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
external: {
endpoint: `http://${dockerAddress}/compose`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
},
},
ownerToken,
).then(r => r.expectNoGraphQLErrors());
expect(
externalCompositionResult.enableExternalSchemaComposition.ok?.externalSchemaComposition
?.endpoint,
externalCompositionResult.updateSchemaComposition.ok?.externalSchemaComposition?.endpoint,
).toBe(`http://${dockerAddress}/compose`);

// set native federation to false to force external composition
Expand Down Expand Up @@ -126,19 +127,20 @@ test.concurrent(
// so we need to use the name and not resolved host
const dockerAddress = await getServiceHost('external_composition', 3012, false);
// enable external composition
const externalCompositionResult = await enableExternalSchemaComposition(
const externalCompositionResult = await updateSchemaComposition(
{
endpoint: `http://${dockerAddress}/fail_on_signature`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
external: {
endpoint: `http://${dockerAddress}/fail_on_signature`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
},
},
ownerToken,
).then(r => r.expectNoGraphQLErrors());
expect(
externalCompositionResult.enableExternalSchemaComposition.ok?.externalSchemaComposition
?.endpoint,
externalCompositionResult.updateSchemaComposition.ok?.externalSchemaComposition?.endpoint,
).toBe(`http://${dockerAddress}/fail_on_signature`);

// set native federation to false to force external composition
Expand Down Expand Up @@ -225,19 +227,20 @@ test.concurrent(
// so we need to use the name and not resolved host
const dockerAddress = await getServiceHost('external_composition', 3012, false);
// enable external composition
const externalCompositionResult = await enableExternalSchemaComposition(
const externalCompositionResult = await updateSchemaComposition(
{
endpoint: `http://${dockerAddress}/non-existing-endpoint`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
external: {
endpoint: `http://${dockerAddress}/non-existing-endpoint`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
},
},
ownerToken,
).then(r => r.expectNoGraphQLErrors());
expect(
externalCompositionResult.enableExternalSchemaComposition.ok?.externalSchemaComposition
?.endpoint,
externalCompositionResult.updateSchemaComposition.ok?.externalSchemaComposition?.endpoint,
).toBe(`http://${dockerAddress}/non-existing-endpoint`);
// set native federation to false to force external composition
await setNativeFederation(false);
Expand Down Expand Up @@ -321,19 +324,20 @@ test.concurrent('a timeout error should be visible to the user', async ({ expect
// so we need to use the name and not resolved host
const dockerAddress = await getServiceHost('external_composition', 3012, false);
// enable external composition
const externalCompositionResult = await enableExternalSchemaComposition(
const externalCompositionResult = await updateSchemaComposition(
{
endpoint: `http://${dockerAddress}/timeout`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
external: {
endpoint: `http://${dockerAddress}/timeout`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
},
},
ownerToken,
).then(r => r.expectNoGraphQLErrors());
expect(
externalCompositionResult.enableExternalSchemaComposition.ok?.externalSchemaComposition
?.endpoint,
externalCompositionResult.updateSchemaComposition.ok?.externalSchemaComposition?.endpoint,
).toBe(`http://${dockerAddress}/timeout`);
// set native federation to false to force external composition
await setNativeFederation(false);
Expand Down
46 changes: 24 additions & 22 deletions integration-tests/tests/api/schema/publish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ import { execute } from 'testkit/graphql';
import { getServiceHost } from 'testkit/utils';
// eslint-disable-next-line import/no-extraneous-dependencies
import { createStorage } from '@hive/storage';
import {
createTarget,
enableExternalSchemaComposition,
publishSchema,
} from '../../../testkit/flow';
import { createTarget, publishSchema, updateSchemaComposition } from '../../../testkit/flow';
import { initSeed } from '../../../testkit/seed';

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

await enableExternalSchemaComposition(
await updateSchemaComposition(
{
endpoint: `http://${serviceAddress}/compose`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
external: {
endpoint: `http://${serviceAddress}/compose`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
},
},
ownerToken,
).then(r => r.expectNoGraphQLErrors());
Expand Down Expand Up @@ -2924,13 +2922,15 @@ test('Composition Network Failure (Federation 2)', async () => {
);
const readWriteToken = await createTargetAccessToken({});

await enableExternalSchemaComposition(
await updateSchemaComposition(
{
endpoint: `http://${serviceAddress}/compose`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
external: {
endpoint: `http://${serviceAddress}/compose`,
// eslint-disable-next-line no-process-env
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
},
},
ownerToken,
).then(r => r.expectNoGraphQLErrors());
Expand Down Expand Up @@ -2965,12 +2965,14 @@ test('Composition Network Failure (Federation 2)', async () => {
return;
}

await enableExternalSchemaComposition(
await updateSchemaComposition(
{
endpoint: `http://${serviceAddress}/no_compose`,
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
external: {
endpoint: `http://${serviceAddress}/no_compose`,
secret: process.env.EXTERNAL_COMPOSITION_SECRET!,
projectSlug: project.slug,
organizationSlug: organization.slug,
},
},
ownerToken,
).then(r => r.expectNoGraphQLErrors());
Expand Down
Loading
Loading