diff --git a/packages/web/app/src/lib/urql.ts b/packages/web/app/src/lib/urql.ts index 68559bef22a..f8ab7b686a6 100644 --- a/packages/web/app/src/lib/urql.ts +++ b/packages/web/app/src/lib/urql.ts @@ -89,6 +89,85 @@ export const urqlClient = createClient({ ProjectTargetsResourceAssignment: noKey, ProjectResourceAssignment: noKey, BillingConfiguration: noKey, + SchemaChangeMeta: noKey, + SchemaCheckMeta: noKey, + FieldArgumentDescriptionChanged: noKey, + FieldArgumentTypeChanged: noKey, + DirectiveRemoved: noKey, + DirectiveAdded: noKey, + DirectiveDescriptionChanged: noKey, + DirectiveLocationAdded: noKey, + DirectiveLocationRemoved: noKey, + DirectiveArgumentAdded: noKey, + DirectiveArgumentRemoved: noKey, + DirectiveArgumentDescriptionChanged: noKey, + DirectiveArgumentDefaultValueChanged: noKey, + DirectiveArgumentTypeChanged: noKey, + EnumValueRemoved: noKey, + EnumValueAdded: noKey, + EnumValueDescriptionChanged: noKey, + EnumValueDeprecationReasonChanged: noKey, + EnumValueDeprecationReasonAdded: noKey, + EnumValueDeprecationReasonRemoved: noKey, + FieldRemoved: noKey, + FieldAdded: noKey, + FieldDescriptionChanged: noKey, + FieldDescriptionAdded: noKey, + FieldDescriptionRemoved: noKey, + FieldDeprecationAdded: noKey, + FieldDeprecationRemoved: noKey, + FieldDeprecationReasonChanged: noKey, + FieldDeprecationReasonAdded: noKey, + FieldDeprecationReasonRemoved: noKey, + FieldTypeChanged: noKey, + DirectiveUsageUnionMemberAdded: noKey, + DirectiveUsageUnionMemberRemoved: noKey, + FieldArgumentAdded: noKey, + FieldArgumentRemoved: noKey, + InputFieldRemoved: noKey, + InputFieldAdded: noKey, + InputFieldDescriptionAdded: noKey, + InputFieldDescriptionRemoved: noKey, + InputFieldDescriptionChanged: noKey, + InputFieldDefaultValueChanged: noKey, + InputFieldTypeChanged: noKey, + ObjectTypeInterfaceAdded: noKey, + ObjectTypeInterfaceRemoved: noKey, + SchemaQueryTypeChanged: noKey, + SchemaMutationTypeChanged: noKey, + SchemaSubscriptionTypeChanged: noKey, + TypeRemoved: noKey, + TypeAdded: noKey, + TypeKindChanged: noKey, + TypeDescriptionChanged: noKey, + TypeDescriptionAdded: noKey, + TypeDescriptionRemoved: noKey, + UnionMemberRemoved: noKey, + UnionMemberAdded: noKey, + DirectiveUsageEnumAdded: noKey, + DirectiveUsageEnumRemoved: noKey, + DirectiveUsageEnumValueAdded: noKey, + DirectiveUsageEnumValueRemoved: noKey, + DirectiveUsageInputObjectRemoved: noKey, + DirectiveUsageInputObjectAdded: noKey, + DirectiveUsageInputFieldDefinitionAdded: noKey, + DirectiveUsageInputFieldDefinitionRemoved: noKey, + DirectiveUsageFieldAdded: noKey, + DirectiveUsageFieldRemoved: noKey, + DirectiveUsageScalarAdded: noKey, + DirectiveUsageScalarRemoved: noKey, + DirectiveUsageObjectAdded: noKey, + DirectiveUsageObjectRemoved: noKey, + DirectiveUsageInterfaceAdded: noKey, + DirectiveUsageSchemaAdded: noKey, + DirectiveUsageSchemaRemoved: noKey, + DirectiveUsageFieldDefinitionAdded: noKey, + DirectiveUsageFieldDefinitionRemoved: noKey, + DirectiveUsageArgumentDefinitionRemoved: noKey, + DirectiveUsageInterfaceRemoved: noKey, + DirectiveUsageArgumentDefinitionAdded: noKey, + DirectiveUsageArgumentAdded: noKey, + DirectiveUsageArgumentRemoved: noKey, }, globalIDs: ['SuccessfulSchemaCheck', 'FailedSchemaCheck'], }), diff --git a/packages/web/app/src/pages/target-proposal-types.ts b/packages/web/app/src/pages/target-proposal-types.ts index 5f617cf833d..ecfa7f1d2dc 100644 --- a/packages/web/app/src/pages/target-proposal-types.ts +++ b/packages/web/app/src/pages/target-proposal-types.ts @@ -8,6 +8,7 @@ export type ServiceProposalDetails = { compositionErrors?: FragmentType; beforeSchema: GraphQLSchema | null; afterSchema: GraphQLSchema | null; + buildError: Error | null; allChanges: Change[]; // Required because the component ChangesBlock uses this fragment. rawChanges: FragmentType[]; diff --git a/packages/web/app/src/pages/target-proposal.tsx b/packages/web/app/src/pages/target-proposal.tsx index 19fb9c9994c..6570d258c7d 100644 --- a/packages/web/app/src/pages/target-proposal.tsx +++ b/packages/web/app/src/pages/target-proposal.tsx @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { buildSchema } from 'graphql'; +import { buildSchema, GraphQLSchema } from 'graphql'; import { useMutation, useQuery, UseQueryExecute } from 'urql'; import { Page, TargetLayout } from '@/components/layouts/target'; import { CompositionErrorsSection_SchemaErrorConnection } from '@/components/target/history/errors-and-changes'; @@ -224,6 +224,9 @@ const ProposalsContent = (props: Parameters[0] // Takes all the data provided by the queries to apply the patch to the schema and // categorize changes. const services = useMemo(() => { + if (changesQuery.fetching || query.fetching) { + return []; + } return ( changesQuery.data?.schemaProposal?.checks?.edges?.map( ({ node: proposalVersion }): ServiceProposalDetails => { @@ -241,6 +244,7 @@ const ProposalsContent = (props: Parameters[0] latestSchema.__typename === 'SingleSchema' /* && (proposalVersion.serviceName == null || proposalVersion.serviceName === '') */, )?.node.source; + const beforeSchema = existingSchema?.length ? buildSchema(existingSchema, { assumeValid: true, assumeValidSDL: true }) : null; @@ -266,21 +270,34 @@ const ProposalsContent = (props: Parameters[0] }) ?? []; const conflictingChanges: Array<{ change: Change; error: Error }> = []; const ignoredChanges: Array<{ change: Change; error: Error }> = []; - const afterSchema = beforeSchema - ? patchSchema(beforeSchema, allChanges, { - onError(error, change) { - if (error instanceof NoopError) { - ignoredChanges.push({ change, error }); - } - conflictingChanges.push({ change, error }); - return errors.looseErrorHandler(error, change); - }, - }) - : buildSchema(proposalVersion.schemaSDL, { assumeValid: true, assumeValidSDL: true }); + let buildError: Error | null = null; + let afterSchema: GraphQLSchema | null = null; + if (beforeSchema) { + afterSchema = patchSchema(beforeSchema, allChanges, { + onError(error, change) { + if (error instanceof NoopError) { + ignoredChanges.push({ change, error }); + } + conflictingChanges.push({ change, error }); + return errors.looseErrorHandler(error, change); + }, + }); + } else { + try { + afterSchema = buildSchema(proposalVersion.schemaSDL, { + assumeValid: true, + assumeValidSDL: true, + }); + } catch (e: unknown) { + console.error(e); + buildError = e as Error; + } + } return { beforeSchema, afterSchema, + buildError, allChanges, rawChanges: proposalVersion.schemaChanges?.edges.map(({ node }) => node) ?? [], conflictingChanges, @@ -295,6 +312,8 @@ const ProposalsContent = (props: Parameters[0] // @todo handle pagination changesQuery.data?.schemaProposal?.checks?.edges, query.data?.latestValidVersion?.schemas.edges, + changesQuery.fetching, + query.fetching, ]); const proposal = query.data?.schemaProposal;