Skip to content

useSuspenseQuery correct usage #11

Open
@Dan86de

Description

@Dan86de

Having problem right now to make TS happy. Is this currently proper usage useSuspenseQuery? More info about my below:

const { data } = useSuspenseQuery(
    // INFO: This is a workaround to get the data from the query (https://github.com/get-convex/convex-react-query/issues/8)
    // @ts-expect-error
    convexQuery(api.transactions.getByType, { type: "income" }),
  );

export const getByType = query({
  args: {
    type: v.union(v.literal("income"), v.literal("expense")),
  },
  handler: async (ctx, args) => {
    const user = await getCurrentUserOrThrow(ctx);

    return await ctx.db
      .query("transactions")
      .withIndex("by_userId", (q) => q.eq("userId", user._id))
      .filter((q) => q.eq(q.field("type"), args.type))
      .collect();
  },
});

Thing is wo @ts-expect-error I'm not able to use this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions