Skip to content

Commit bbd5643

Browse files
authored
Advanced breaking change detection for input and argument values (#6764)
1 parent 54acc25 commit bbd5643

File tree

9 files changed

+1044
-19
lines changed

9 files changed

+1044
-19
lines changed

.changeset/early-eyes-return.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-hive/core': minor
3+
'hive': minor
4+
---
5+
6+
Track provided operation arguments/inputs and use them to determine conditional breaking changes;
7+
Fix null to non-null argument breaking change edge case"

integration-tests/testkit/flow.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,32 @@ export function waitFor(ms: number) {
3838
return new Promise(resolve => setTimeout(resolve, ms));
3939
}
4040

41+
function pollInternal(
42+
check: () => Promise<boolean>,
43+
pollFrequency: number,
44+
resolve: (value: void | PromiseLike<void>) => void,
45+
reject: (reason?: any) => void,
46+
) {
47+
setTimeout(async () => {
48+
try {
49+
const passes = await check();
50+
if (passes) {
51+
resolve();
52+
} else {
53+
pollInternal(check, pollFrequency, resolve, reject);
54+
}
55+
} catch (e) {
56+
reject(e);
57+
}
58+
}, pollFrequency);
59+
}
60+
61+
export function pollFor(check: () => Promise<boolean>, pollFrequency = 500): Promise<void> {
62+
return new Promise((resolve, reject) => {
63+
pollInternal(check, pollFrequency, resolve, reject);
64+
});
65+
}
66+
4167
export function createOrganization(input: CreateOrganizationInput, authToken: string) {
4268
return execute({
4369
document: graphql(`

integration-tests/testkit/seed.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { formatISO, subHours } from 'date-fns';
12
import { humanId } from 'human-id';
23
import { createPool, sql } from 'slonik';
34
import type { Report } from '../../packages/libraries/core/src/client/usage.js';
@@ -39,6 +40,7 @@ import {
3940
getOrganizationProjects,
4041
inviteToOrganization,
4142
joinOrganization,
43+
pollFor,
4244
publishSchema,
4345
readClientStats,
4446
readOperationBody,
@@ -666,6 +668,7 @@ export function initSeed() {
666668
.conditionalBreakingChangeConfiguration;
667669
},
668670
async updateTargetValidationSettings({
671+
isEnabled,
669672
excludedClients,
670673
percentage,
671674
target: ttarget = target,
@@ -684,6 +687,7 @@ export function initSeed() {
684687
},
685688
},
686689
conditionalBreakingChangeConfiguration: {
690+
isEnabled,
687691
excludedClients,
688692
percentage,
689693
requestCount,
@@ -725,6 +729,32 @@ export function initSeed() {
725729

726730
return operationBodyResult?.target?.operation?.body;
727731
},
732+
async waitForOperationsCollected(
733+
n: number,
734+
_from?: number,
735+
_to?: number,
736+
ttarget: TargetOverwrite = target,
737+
) {
738+
const from = formatISO(_from ?? subHours(Date.now(), 1));
739+
const to = formatISO(_to ?? Date.now());
740+
const check = async () => {
741+
const statsResult = await readOperationsStats(
742+
{
743+
organizationSlug: organization.slug,
744+
projectSlug: project.slug,
745+
targetSlug: ttarget.slug,
746+
period: {
747+
from,
748+
to,
749+
},
750+
},
751+
ownerToken,
752+
).then(r => r.expectNoGraphQLErrors());
753+
return statsResult.operationsStats.totalOperations == n;
754+
};
755+
756+
return pollFor(check);
757+
},
728758
async readOperationsStats(
729759
from: string,
730760
to: string,

0 commit comments

Comments
 (0)