Skip to content

Commit ae65069

Browse files
authored
feat(api): manage contracts via public api (#6810)
1 parent c20f01e commit ae65069

File tree

9 files changed

+126
-96
lines changed

9 files changed

+126
-96
lines changed

.changeset/fast-trees-call.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'hive': major
3+
---
4+
5+
Add mutation fields for managing schema contracts to the public api schema.
6+
7+
- `Mutation.createContract`
8+
- `Mutation.disableContract`
9+
10+
**BREAKING CHANGE**: This renames and changes the types for existing types within the private GraphQL schema.

integration-tests/tests/api/schema/contracts-check.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const CreateContractMutation = graphql(`
2020
error {
2121
message
2222
details {
23-
targetId
23+
target
2424
contractName
2525
includeTags
2626
excludeTags
@@ -67,7 +67,7 @@ test.concurrent('schema check with successful contract checks', async ({ expect
6767
document: CreateContractMutation,
6868
variables: {
6969
input: {
70-
targetId: target.id,
70+
target: { byId: target.id },
7171
contractName: 'my-contract',
7272
removeUnreachableTypesFromPublicApiSchema: true,
7373
excludeTags: ['toyota'],
@@ -134,7 +134,7 @@ test.concurrent('schema check with failing contract composition', async ({ expec
134134
document: CreateContractMutation,
135135
variables: {
136136
input: {
137-
targetId: target.id,
137+
target: { byId: target.id },
138138
contractName: 'my-contract',
139139
removeUnreachableTypesFromPublicApiSchema: true,
140140
excludeTags: ['toyota'],
@@ -215,7 +215,7 @@ test.concurrent(
215215
document: CreateContractMutation,
216216
variables: {
217217
input: {
218-
targetId: target.id,
218+
target: { byId: target.id },
219219
contractName: 'my-contract',
220220
removeUnreachableTypesFromPublicApiSchema: true,
221221
excludeTags: ['toyota'],
@@ -230,7 +230,7 @@ test.concurrent(
230230
document: CreateContractMutation,
231231
variables: {
232232
input: {
233-
targetId: target.id,
233+
target: { byId: target.id },
234234
contractName: 'my-other-contract',
235235
removeUnreachableTypesFromPublicApiSchema: true,
236236
includeTags: ['fiat'],
@@ -399,7 +399,7 @@ test.concurrent(
399399
document: CreateContractMutation,
400400
variables: {
401401
input: {
402-
targetId: target.id,
402+
target: { byId: target.id },
403403
contractName,
404404
removeUnreachableTypesFromPublicApiSchema: true,
405405
includeTags: ['toyota'],
@@ -562,7 +562,7 @@ test.concurrent(
562562
document: CreateContractMutation,
563563
variables: {
564564
input: {
565-
targetId: target.id,
565+
target: { byId: target.id },
566566
contractName,
567567
removeUnreachableTypesFromPublicApiSchema: true,
568568
includeTags: ['toyota'],
@@ -758,7 +758,7 @@ test.concurrent(
758758
document: CreateContractMutation,
759759
variables: {
760760
input: {
761-
targetId: target.id,
761+
target: { byId: target.id },
762762
contractName,
763763
removeUnreachableTypesFromPublicApiSchema: true,
764764
includeTags: ['toyota'],
@@ -947,7 +947,7 @@ test.concurrent(
947947
document: CreateContractMutation,
948948
variables: {
949949
input: {
950-
targetId: target.id,
950+
target: { byId: target.id },
951951
contractName,
952952
removeUnreachableTypesFromPublicApiSchema: true,
953953
includeTags: ['toyota'],
@@ -1146,7 +1146,7 @@ test.concurrent(
11461146
document: CreateContractMutation,
11471147
variables: {
11481148
input: {
1149-
targetId: target.id,
1149+
target: { byId: target.id },
11501150
contractName,
11511151
removeUnreachableTypesFromPublicApiSchema: true,
11521152
includeTags: ['toyota'],
@@ -1255,7 +1255,7 @@ test.concurrent(
12551255
document: CreateContractMutation,
12561256
variables: {
12571257
input: {
1258-
targetId: target.id,
1258+
target: { byId: target.id },
12591259
contractName,
12601260
removeUnreachableTypesFromPublicApiSchema: true,
12611261
includeTags: ['toyota'],

integration-tests/tests/api/schema/contracts-publish.spec.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const CreateContractMutation = graphql(`
2121
error {
2222
message
2323
details {
24-
targetId
24+
target
2525
contractName
2626
includeTags
2727
excludeTags
@@ -101,7 +101,7 @@ test.concurrent(
101101
document: CreateContractMutation,
102102
variables: {
103103
input: {
104-
targetId: target.id,
104+
target: { byId: target.id },
105105
contractName: 'my-contract',
106106
removeUnreachableTypesFromPublicApiSchema: true,
107107
includeTags: ['toyota'],
@@ -192,7 +192,7 @@ test.concurrent('schema publish with failing initial contract composition', asyn
192192
document: CreateContractMutation,
193193
variables: {
194194
input: {
195-
targetId: target.id,
195+
target: { byId: target.id },
196196
contractName: 'my-contract',
197197
removeUnreachableTypesFromPublicApiSchema: true,
198198
excludeTags: ['toyota'],
@@ -253,7 +253,7 @@ test.concurrent('schema publish with succeeding contract composition', async ({
253253
document: CreateContractMutation,
254254
variables: {
255255
input: {
256-
targetId: target.id,
256+
target: { byId: target.id },
257257
contractName: 'my-contract',
258258
removeUnreachableTypesFromPublicApiSchema: true,
259259
includeTags: ['toyota'],
@@ -344,7 +344,7 @@ test.concurrent('schema publish with failing contract composition', async ({ exp
344344
document: CreateContractMutation,
345345
variables: {
346346
input: {
347-
targetId: target.id,
347+
target: { byId: target.id },
348348
contractName: 'my-contract',
349349
removeUnreachableTypesFromPublicApiSchema: true,
350350
excludeTags: ['toyota'],
@@ -472,7 +472,7 @@ test.concurrent(
472472
document: CreateContractMutation,
473473
variables: {
474474
input: {
475-
targetId: target.id,
475+
target: { byId: target.id },
476476
contractName: 'my-contract',
477477
removeUnreachableTypesFromPublicApiSchema: true,
478478
excludeTags: ['toyota'],
@@ -563,7 +563,7 @@ test.concurrent('schema delete with failing initial contract composition', async
563563
document: CreateContractMutation,
564564
variables: {
565565
input: {
566-
targetId: target.id,
566+
target: { byId: target.id },
567567
contractName: 'my-contract',
568568
removeUnreachableTypesFromPublicApiSchema: true,
569569
includeTags: ['toyota'],
@@ -627,7 +627,7 @@ test.concurrent('schema delete with succeeding contract composition', async ({ e
627627
document: CreateContractMutation,
628628
variables: {
629629
input: {
630-
targetId: target.id,
630+
target: { byId: target.id },
631631
contractName: 'my-contract',
632632
removeUnreachableTypesFromPublicApiSchema: true,
633633
excludeTags: ['toyota'],
@@ -717,7 +717,7 @@ test.concurrent('schema delete with failing contract composition', async ({ expe
717717
document: CreateContractMutation,
718718
variables: {
719719
input: {
720-
targetId: target.id,
720+
target: { byId: target.id },
721721
contractName: 'my-contract',
722722
removeUnreachableTypesFromPublicApiSchema: true,
723723
includeTags: ['toyota'],
@@ -781,7 +781,7 @@ test.concurrent(
781781
document: CreateContractMutation,
782782
variables: {
783783
input: {
784-
targetId: target.id,
784+
target: { byId: target.id },
785785
contractName: 'my-contract',
786786
removeUnreachableTypesFromPublicApiSchema: true,
787787
excludeTags: ['toyota'],
@@ -845,7 +845,7 @@ test.concurrent(
845845
document: CreateContractMutation,
846846
variables: {
847847
input: {
848-
targetId: target.id,
848+
target: { byId: target.id },
849849
contractName: 'my-contract',
850850
removeUnreachableTypesFromPublicApiSchema: true,
851851
excludeTags: ['toyota'],
@@ -917,7 +917,7 @@ test.concurrent('disable contract results in CDN artifacts being removed', async
917917
document: CreateContractMutation,
918918
variables: {
919919
input: {
920-
targetId: target.id,
920+
target: { byId: target.id },
921921
contractName: 'my-contract',
922922
removeUnreachableTypesFromPublicApiSchema: true,
923923
excludeTags: ['toyota'],
@@ -972,7 +972,7 @@ test.concurrent('disable contract results in CDN artifacts being removed', async
972972
document: DisabledContractMutation,
973973
variables: {
974974
input: {
975-
contractId,
975+
contract: { byId: contractId },
976976
},
977977
},
978978
authToken: ownerToken,
@@ -1006,7 +1006,7 @@ test.concurrent(
10061006
document: CreateContractMutation,
10071007
variables: {
10081008
input: {
1009-
targetId: target.id,
1009+
target: { byId: target.id },
10101010
contractName: 'my-contract',
10111011
removeUnreachableTypesFromPublicApiSchema: true,
10121012
excludeTags: ['toyota'],
@@ -1029,7 +1029,7 @@ test.concurrent(
10291029
document: DisabledContractMutation,
10301030
variables: {
10311031
input: {
1032-
contractId,
1032+
contract: { byId: contractId },
10331033
},
10341034
},
10351035
authToken: ownerToken,
@@ -1065,7 +1065,7 @@ test.concurrent(
10651065
document: CreateContractMutation,
10661066
variables: {
10671067
input: {
1068-
targetId: target.id,
1068+
target: { byId: target.id },
10691069
contractName: 'my-contract',
10701070
removeUnreachableTypesFromPublicApiSchema: true,
10711071
excludeTags: ['toyota'],
@@ -1086,7 +1086,7 @@ test.concurrent(
10861086
document: DisabledContractMutation,
10871087
variables: {
10881088
input: {
1089-
contractId,
1089+
contract: { byId: contractId },
10901090
},
10911091
},
10921092
authToken: ownerToken,
@@ -1098,7 +1098,7 @@ test.concurrent(
10981098
document: DisabledContractMutation,
10991099
variables: {
11001100
input: {
1101-
contractId,
1101+
contract: { byId: contractId },
11021102
},
11031103
},
11041104
authToken: ownerToken,

0 commit comments

Comments
 (0)