sbkl
sbkl3mo ago

Uncaught Error: The arguments to a Convex function must be an object. Received: skip

Using convex-react-query, I noticed there is a new skip arguments that can be used to disable a query when the arguments is not available yet. But I get this error: Uncaught Error: The arguments to a Convex function must be an object. Received: skip. Which means the convex client complaining about the args. Looked at the code and normally the query shouldn't run at all. Any idea? Maybe I understand it wrong. My code:
export function useGetDocument() {
const params = useParams();
const documentId = params.documentId as Id<"documents"> | undefined;
const query = useQuery(
convexQuery(
api.documents.query.find,
documentId
? {
documentId: documentId as Id<"documents">,
}
: "skip",
),
);

return { documentId, ...query };
}
export function useGetDocument() {
const params = useParams();
const documentId = params.documentId as Id<"documents"> | undefined;
const query = useQuery(
convexQuery(
api.documents.query.find,
documentId
? {
documentId: documentId as Id<"documents">,
}
: "skip",
),
);

return { documentId, ...query };
}
4 Replies
ballingt
ballingt3mo ago
@sbkl this was just added, looks like it doesn't work yet; "skip" is usually handled at the hook layer but that layer is skipped in this implementation
ballingt
ballingt3mo ago
GitHub
"skip" is shown in types but doesn't work yet · Issue #8 · get-conv...
Making "skip" explicit in the types was a quick way to fix the new types for useSuspenseQuery but it doesn't actually work yet!
ballingt
ballingt3mo ago
@sbkl Just published @convex-dev/react-query@0.0.0-alpha.8 which has a first pass for this
sbkl
sbklOP3mo ago
Works like a charm! thank you. Was getting some errors because of this when the url params wasn't available. But not anymore!

Did you find this page helpful?