Skip to content
Draft
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
6 changes: 6 additions & 0 deletions .changeset/approve-check-skip-sdl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'hive': patch
---

Approving a failed schema check through the GraphQL API no longer loads the SDLs and schema changes
of the check unless the mutation's selection reads them.
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,10 @@ export class SchemaManager {
schemaCheckId: string;
comment: string | null | undefined;
author?: string | null;
/** Whether the returned check includes its SDLs. Defaults to true. */
withSDL?: boolean;
/** Whether the returned check includes its schema changes. Defaults to true. */
withChanges?: boolean;
}) {
this.logger.debug('Manually approve failed schema check (args=%o)', args);

Expand Down Expand Up @@ -1146,6 +1150,8 @@ export class SchemaManager {
userId: viewer?.id ?? null,
comment: args.comment,
author: args.author ?? null,
withSDL: args.withSDL,
withChanges: args.withChanges,
});

if (!schemaCheck) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { IdTranslator } from '../../../shared/providers/id-translator';
import { SchemaManager } from '../../providers/schema-manager';
import { toGraphQLSchemaCheck } from '../../to-graphql-schema-check';
import { areSchemaCheckChangesRequested, isSDLRequested } from '../Target';
import type { MutationResolvers } from './../../../../__generated__/types';

export const approveFailedSchemaCheck: NonNullable<
MutationResolvers['approveFailedSchemaCheck']
> = async (_, { input }, { injector }) => {
> = async (_, { input }, { injector }, info) => {
const [organizationId, projectId, targetId] = await Promise.all([
injector.get(IdTranslator).translateOrganizationId(input),
injector.get(IdTranslator).translateProjectId(input),
Expand All @@ -19,6 +20,9 @@ export const approveFailedSchemaCheck: NonNullable<
schemaCheckId: input.schemaCheckId,
comment: input.comment,
author: input.author,
// Only load what the mutation's selection reads.
withSDL: isSDLRequested(info),
withChanges: areSchemaCheckChangesRequested(info),
});

if (result.type === 'error') {
Expand Down
4 changes: 4 additions & 0 deletions packages/services/api/src/modules/shared/providers/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ export interface Storage {
userId: string | null;
comment: string | null | undefined;
author: string | null | undefined;
/** Whether the returned check includes its six SDLs; their fields come back empty otherwise. Defaults to true. */
withSDL?: boolean;
/** Whether the returned check includes its safe and breaking changes. Defaults to true. */
withChanges?: boolean;
}): Promise<SchemaCheck | null>;

/**
Expand Down
22 changes: 6 additions & 16 deletions packages/services/storage/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2793,22 +2793,12 @@ export async function createStorage(
return null;
}

const result = await pool.maybeOne(psql`/* getApprovedSchemaCheck */
SELECT
${schemaCheckSQLFields()}
FROM
"schema_checks" as c
LEFT JOIN "sdl_store" as s_schema ON s_schema."id" = c."schema_sdl_store_id"
LEFT JOIN "sdl_store" as s_baseline_schema ON s_baseline_schema."id" = c."baseline_schema_sdl_store_id"
LEFT JOIN "sdl_store" as s_baseline_public ON s_baseline_public."id" = c."baseline_composite_schema_sdl_store_id"
LEFT JOIN "sdl_store" as s_baseline_supergraph ON s_baseline_supergraph."id" = c."baseline_supergraph_sdl_store_id"
LEFT JOIN "sdl_store" as s_composite_schema ON s_composite_schema."id" = c."composite_schema_sdl_store_id"
LEFT JOIN "sdl_store" as s_supergraph ON s_supergraph."id" = c."supergraph_sdl_store_id"
WHERE
c."id" = ${updateResult.id}
`);

return SchemaCheckModel.parse(result);
return await this.findSchemaCheck({
targetId: args.targetId,
schemaCheckId: updateResult.id,
withSDL: args.withSDL,
withChanges: args.withChanges,
});
},
async getApprovedSchemaChangesForContextId(args) {
const result = await pool.anyFirst(psql`/* getApprovedSchemaChangesForContextId */
Expand Down
Loading