Skip to content

Commit a7e92e4

Browse files
authored
fix: useInvoices, usePrefetchBranchDirEntry, BundleTrendQueryOpts, usePullComponents schemas (#3809)
1 parent 7f57f59 commit a7e92e4

File tree

5 files changed

+42
-35
lines changed

5 files changed

+42
-35
lines changed

src/pages/PullRequestPage/PullCoverage/routes/ComponentsSelector/ComponentsSelector.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function ComponentsSelector() {
2525
})
2626

2727
const components = useMemo(() => {
28-
return data?.pull?.compareWithBase.__typename === 'Comparison'
28+
return data?.pull?.compareWithBase?.__typename === 'Comparison'
2929
? data?.pull?.compareWithBase?.componentComparisons
3030
: []
3131
}, [data])

src/services/account/useInvoices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const InvoicesSchema = z.array(InvoiceSchema)
6161
const OwnerInvoiceSchema = z.object({
6262
owner: z
6363
.object({
64-
invoices: InvoicesSchema,
64+
invoices: InvoicesSchema.nullable(),
6565
})
6666
.nullable(),
6767
})

src/services/bundleAnalysis/BundleTrendDataQueryOpts.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,12 @@ const BranchSchema = z.object({
5151
.object({
5252
bundleAnalysis: z
5353
.object({
54-
bundleAnalysisReport: z.discriminatedUnion('__typename', [
55-
BundleReportSchema,
56-
MissingHeadReportSchema,
57-
]),
54+
bundleAnalysisReport: z
55+
.discriminatedUnion('__typename', [
56+
BundleReportSchema,
57+
MissingHeadReportSchema,
58+
])
59+
.nullable(),
5860
})
5961
.nullable(),
6062
})
@@ -228,7 +230,10 @@ export const BundleTrendDataQueryOpts = ({
228230
data.owner?.repository?.branch?.head?.bundleAnalysis
229231
?.bundleAnalysisReport
230232

231-
if (bundleReport?.__typename === 'BundleAnalysisReport') {
233+
if (
234+
bundleReport &&
235+
bundleReport?.__typename === 'BundleAnalysisReport'
236+
) {
232237
return bundleReport?.bundle?.measurements
233238
}
234239

src/services/pathContents/branch/dir/usePrefetchBranchDirEntry.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,15 @@ const PathContentsUnionSchema = z.discriminatedUnion('__typename', [
7575
const RepositorySchema = z.object({
7676
__typename: z.literal('Repository'),
7777
repositoryConfig: RepositoryConfigSchema,
78-
branch: z.object({
79-
head: z
80-
.object({
81-
deprecatedPathContents: PathContentsUnionSchema.nullish(),
82-
})
83-
.nullable(),
84-
}),
78+
branch: z
79+
.object({
80+
head: z
81+
.object({
82+
deprecatedPathContents: PathContentsUnionSchema.nullish(),
83+
})
84+
.nullable(),
85+
})
86+
.nullable(),
8587
})
8688

8789
const BranchContentsSchema = z.object({

src/services/pull/usePullComponents.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,24 +69,26 @@ const RepositorySchema = z.object({
6969
__typename: z.literal('Repository'),
7070
pull: z
7171
.object({
72-
compareWithBase: z.discriminatedUnion('__typename', [
73-
z.object({
74-
__typename: z.literal('Comparison'),
75-
componentComparisons: z
76-
.array(
77-
z.object({
78-
name: z.string(),
79-
})
80-
)
81-
.nullable(),
82-
}),
83-
FirstPullRequestSchema,
84-
MissingBaseCommitSchema,
85-
MissingBaseReportSchema,
86-
MissingComparisonSchema,
87-
MissingHeadCommitSchema,
88-
MissingHeadReportSchema,
89-
]),
72+
compareWithBase: z
73+
.discriminatedUnion('__typename', [
74+
z.object({
75+
__typename: z.literal('Comparison'),
76+
componentComparisons: z
77+
.array(
78+
z.object({
79+
name: z.string(),
80+
})
81+
)
82+
.nullable(),
83+
}),
84+
FirstPullRequestSchema,
85+
MissingBaseCommitSchema,
86+
MissingBaseReportSchema,
87+
MissingComparisonSchema,
88+
MissingHeadCommitSchema,
89+
MissingHeadReportSchema,
90+
])
91+
.nullable(),
9092
})
9193
.nullable(),
9294
})
@@ -193,9 +195,7 @@ export function usePullComponents({
193195
})
194196
}
195197

196-
return {
197-
pull: data?.owner?.repository?.pull,
198-
}
198+
return { pull: data?.owner?.repository?.pull }
199199
}),
200200
...options,
201201
})

0 commit comments

Comments
 (0)