Skip to content

Commit ccad381

Browse files
committed
unify with QueryOptions and require args
1 parent 44a4677 commit ccad381

File tree

2 files changed

+15
-30
lines changed

2 files changed

+15
-30
lines changed

npm-packages/convex/src/react/client.ts

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -808,36 +808,20 @@ export type OptionalRestArgsOrSkip<FuncRef extends FunctionReference<any>> =
808808
*
809809
* @public
810810
*/
811-
export type UseQueryOptions<Query extends FunctionReference<"query">> = {
812-
/**
813-
* The query function to run.
814-
*/
815-
query: Query;
816-
/**
817-
* Whether to throw an error if the query fails.
818-
* If false, the error will be returned in the `error` field.
819-
* @defaultValue false
820-
*/
821-
throwOnError?: boolean;
822-
/**
823-
* An initial value to use before the query result is available.
824-
* @defaultValue undefined
825-
*/
826-
initialValue?: Query["_returnType"];
827-
} & (FunctionArgs<Query> extends EmptyObject
828-
? {
829-
/**
830-
* The arguments to the query function.
831-
* Optional for queries with no arguments.
832-
*/
833-
args?: FunctionArgs<Query>;
834-
}
835-
: {
836-
/**
837-
* The arguments to the query function.
838-
*/
839-
args: FunctionArgs<Query>;
840-
});
811+
export type UseQueryOptions<Query extends FunctionReference<"query">> =
812+
QueryOptions<Query> & {
813+
/**
814+
* Whether to throw an error if the query fails.
815+
* If false, the error will be returned in the `error` field.
816+
* @defaultValue false
817+
*/
818+
throwOnError?: boolean;
819+
/**
820+
* An initial value to use before the query result is available.
821+
* @defaultValue undefined
822+
*/
823+
initialValue?: Query["_returnType"];
824+
};
841825

842826
/**
843827
* Options for the object-based {@link useQuery} overload with a preloaded query.

npm-packages/convex/src/react/use_query.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ describe("useQuery types", () => {
7373
test("Queries with object options", () => {
7474
useQuery({
7575
query: api.module.noArgs,
76+
args: {},
7677
});
7778

7879
useQuery({

0 commit comments

Comments
 (0)