We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is currently a discrepancy between the type signatures of regular operations (actions/queries) and CRUD operations.
export type GetTemplate<Input extends Payload = never, Output extends Payload = Payload> = AuthenticatedQueryDefinition<[_Template], Input, Output>;
type GetQuery<Input extends Payload, Output extends Payload> = AuthenticatedQueryDefinition<[_WaspEntityTagged], Input, Output>;
The critical difference is in the default type parameters:
<Input extends Payload = never, Output extends Payload = Payload>
= never
= Payload
<Input extends Payload, Output extends Payload>
This means that for regular operations, the output type can be set using the satisfies keyword, e.g.
satisfies
export const getAllTasks = async (_args, context) => { return context.entities.Task.findMany({ ... }) satisfies GetAllTasks<void>; };
and on the client-side, the query type can be inferred:
Awaited<ReturnType<typeof getAllTasks>>[0];
But this technique fails for CRUD operations due to the lack of default values in the type definitions.
To Reproduce Steps to reproduce the behavior:
crud Tasks { entity: Task, operations: { getAll: { isPublic: true, // by default only logged in users can perform operations overrideFn: import { getAllTasks } from "@src/tasks.ts", }, get: {}, create: {}, update: {}, }, }
import { Tasks } from 'wasp/server/crud/Tasks'; export const getAllTasks = (async (_args, context) => { return await context.entities.Task.findMany(); }) satisfies Tasks.GetAllQuery<void>;
Generic type 'GetAllQuery' requires 2 type argument(s).
Expected behavior The CRUD function should work in the same way as a regular operation, allowing for client-side query type inference.
Additional context Present in Wasp 0.16.2
The text was updated successfully, but these errors were encountered:
Successfully merging a pull request may close this issue.
There is currently a discrepancy between the type signatures of regular operations (actions/queries) and CRUD operations.
Operation Type Definition:
CRUD Operation Type Definition:
The critical difference is in the default type parameters:
<Input extends Payload = never, Output extends Payload = Payload>
= never
and= Payload
parts provide default values<Input extends Payload, Output extends Payload>
This means that for regular operations, the output type can be set using the
satisfies
keyword, e.g.and on the client-side, the query type can be inferred:
But this technique fails for CRUD operations due to the lack of default values in the type definitions.
To Reproduce
Steps to reproduce the behavior:
Generic type 'GetAllQuery' requires 2 type argument(s).
Expected behavior
The CRUD function should work in the same way as a regular operation, allowing for client-side query type inference.
Additional context
Present in Wasp 0.16.2
The text was updated successfully, but these errors were encountered: