mirror of
https://github.com/graphql-hive/console
synced 2026-04-21 14:37:17 +00:00
fix: chema sdl resolver to ignore auto fix composite schema execution… (#7614)
This commit is contained in:
parent
b344569706
commit
e853916513
5 changed files with 59 additions and 4 deletions
5
.changeset/afraid-pans-thank.md
Normal file
5
.changeset/afraid-pans-thank.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'hive': patch
|
||||
---
|
||||
|
||||
Fix for schema sdl resolver to ignore auto fix composite schema execution in case of monolith
|
||||
|
|
@ -1242,6 +1242,7 @@ export function fetchLatestValidSchema(token: string) {
|
|||
}
|
||||
}
|
||||
tags
|
||||
sdl
|
||||
schemas {
|
||||
nodes {
|
||||
... on SingleSchema {
|
||||
|
|
|
|||
|
|
@ -67,3 +67,34 @@ test.concurrent(
|
|||
expect(result.schemaVersionByCommit?.sdl).toIncludeSubstringWithoutWhitespace(latestSchema);
|
||||
},
|
||||
);
|
||||
|
||||
test.concurrent('valid monolith schema ignores the schema composition auto fix', async () => {
|
||||
const { createOrg } = await initSeed().createOwner();
|
||||
const { createProject } = await createOrg();
|
||||
const { createTargetAccessToken } = await createProject(ProjectType.Single);
|
||||
const token = await createTargetAccessToken({});
|
||||
|
||||
const sdl = /* GraphQL */ `
|
||||
schema {
|
||||
query: RootQueryType
|
||||
}
|
||||
|
||||
type Link {
|
||||
link: String
|
||||
}
|
||||
|
||||
type RootQueryType {
|
||||
foo: Link
|
||||
}
|
||||
`;
|
||||
|
||||
await token
|
||||
.publishSchema({
|
||||
sdl,
|
||||
})
|
||||
.then(r => r.expectNoGraphQLErrors());
|
||||
|
||||
const schema = await token.fetchLatestValidSchema();
|
||||
|
||||
expect(schema.latestValidVersion?.sdl).toMatchInlineSnapshot(sdl);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -105,12 +105,17 @@ export class SchemaVersionHelper {
|
|||
|
||||
async getCompositeSchemaSdl(schemaVersion: SchemaVersion) {
|
||||
if (schemaVersion.hasPersistedSchemaChanges) {
|
||||
if (!schemaVersion.supergraphSDL) {
|
||||
return schemaVersion.compositeSchemaSDL;
|
||||
}
|
||||
|
||||
return schemaVersion.compositeSchemaSDL
|
||||
? this.autoFixCompositeSchemaSdl(schemaVersion.compositeSchemaSDL, schemaVersion.id)
|
||||
: null;
|
||||
}
|
||||
|
||||
const composition = await this.composeSchemaVersion(schemaVersion);
|
||||
|
||||
if (composition === null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -134,6 +139,7 @@ export class SchemaVersionHelper {
|
|||
@cache<SchemaVersion>(version => version.id)
|
||||
async getCompositeSchemaAst(schemaVersion: SchemaVersion) {
|
||||
const compositeSchemaSdl = await this.getCompositeSchemaSdl(schemaVersion);
|
||||
|
||||
if (compositeSchemaSdl === null) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import { useCallback, useEffect, useMemo } from 'react';
|
|||
import clsx from 'clsx';
|
||||
import { buildSchema, introspectionFromSchema } from 'graphql';
|
||||
import { throttle } from 'lodash';
|
||||
import { toast } from 'sonner';
|
||||
import { useMutation, useQuery } from 'urql';
|
||||
import { Page, TargetLayout } from '@/components/layouts/target';
|
||||
import { ConnectLabModal } from '@/components/target/laboratory/connect-lab-modal';
|
||||
|
|
@ -605,10 +606,21 @@ function LaboratoryPageContent(props: {
|
|||
});
|
||||
|
||||
const sdl = query.data?.target?.latestSchemaVersion?.sdl;
|
||||
const introspection = useMemo(
|
||||
() => (sdl ? introspectionFromSchema(buildSchema(sdl)) : null),
|
||||
[sdl],
|
||||
);
|
||||
|
||||
const introspection = useMemo(() => {
|
||||
if (!sdl) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return introspectionFromSchema(buildSchema(sdl));
|
||||
} catch (err) {
|
||||
toast.error('Failed to fetch schema', {
|
||||
description: err instanceof Error ? err.message : 'Unknown error',
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}, [sdl]);
|
||||
|
||||
if (laboratoryState.fetching) {
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue