Skip to content

Commit

Permalink
update documentByDocumentIdQueryOptions to make sure that query throw…
Browse files Browse the repository at this point in the history
…s when match is not found
  • Loading branch information
achou11 committed Dec 11, 2024
1 parent 95f7249 commit c321820
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lib/react-query/documents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function documentByDocumentIdQueryOptions<D extends DocumentType>({
projectId: string
docType: D
docId: Parameters<MapeoProjectApi[D]['getByDocId']>[0]
opts?: Parameters<MapeoProjectApi[D]['getByDocId']>[1]
opts?: Omit<Parameters<MapeoProjectApi[D]['getByDocId']>[1], 'mustBeFound'>
}) {
return queryOptions({
...baseQueryOptions(),
Expand All @@ -108,7 +108,11 @@ export function documentByDocumentIdQueryOptions<D extends DocumentType>({
opts,
}),
queryFn: async () => {
return projectApi[docType].getByDocId(docId, opts)
return projectApi[docType].getByDocId(docId, {
...opts,
// We want to make sure that this throws in the case that no match is found
mustBeFound: true,
})
},
})
}
Expand Down

0 comments on commit c321820

Please sign in to comment.