Closed panzacoder closed 1 month ago
Yeah I noticed this too. I suspect when we either add return type validators, or when the validator types changed (1.13) the resulting change made TypeScript see the resulting custom function as not conforming to typeof query
.
I have a fix in convex-helpers@0.1.57-alpha.1
Can you verify it works for you @panzacoder?
Yes that worked!!! I have been poking at the types for a bit in my node_modules but couldn't find the right adjustment. Thank you @ianmacartney!
Sweet - let me know if there are any issues at runtime - I'll put it out in the next major release.
By the way, I am planning to update the API to just take in the schema and table name:
import schema from "./schema";
crud(schema, "users", authQuery, mutationWithRLS);
So you don't have to use Table to use it.
It's in convex-helpers@0.1.57-alpha.2
This would be a breaking change, so I'm curious whether this would be too disruptive for you / if there's a reason you'd prefer it the old way? I could make a new version and deprecate the old version if it'd be a problem.
import schema from "./schema"; crud(schema, "users", authQuery, mutationWithRLS);
Interesting. Seems easier for sure, although I would definitely just wrap it in another function so I don't have to import and pass the schema everywhere (if I'm understanding the change right).
To answer the question directly though, not a big deal to refactor this.
Yeah you could have a helper that you give the schema once and only takes in the table name for other declarations. It also has the second two arguments optional (defaults to internalQuery / internalMutation) - so for making internal crud apis it's only
export const { read, update } = crud(schema, "users");
On Tue, Sep 10, 2024 at 6:27 PM Jake Hebert @.***> wrote:
import schema from "./schema"; crud(schema, "users", authQuery, mutationWithRLS);
Interesting. Seems easier for sure, although I would definitely just wrap it in another function so I don't have to import and pass the schema everywhere (if I'm understanding the change right).
To answer the question directly though, not a big deal to refactor this.
— Reply to this email directly, view it on GitHub https://github.com/get-convex/convex-helpers/issues/250#issuecomment-2342435760, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACZQW3HHJTVAL6FLI5ZPW3ZV6L77AVCNFSM6AAAAABN6H5OX2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBSGQZTKNZWGA . You are receiving this because you modified the open/close state.Message ID: @.***>
I'm going to go ahead with it at some point, then. Thanks for validating
On Tue, Sep 10, 2024 at 10:58 PM Ian Macartney @.***> wrote:
Yeah you could have a helper that you give the schema once and only takes in the table name for other declarations. It also has the second two arguments optional (defaults to internalQuery / internalMutation) - so for making internal crud apis it's only
export const { read, update } = crud(schema, "users");
On Tue, Sep 10, 2024 at 6:27 PM Jake Hebert @.***> wrote:
import schema from "./schema"; crud(schema, "users", authQuery, mutationWithRLS);
Interesting. Seems easier for sure, although I would definitely just wrap it in another function so I don't have to import and pass the schema everywhere (if I'm understanding the change right).
To answer the question directly though, not a big deal to refactor this.
— Reply to this email directly, view it on GitHub https://github.com/get-convex/convex-helpers/issues/250#issuecomment-2342435760, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACZQW3HHJTVAL6FLI5ZPW3ZV6L77AVCNFSM6AAAAABN6H5OX2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNBSGQZTKNZWGA . You are receiving this because you modified the open/close state.Message ID: @.***>
I published the version with schema in 0.1.58
at convex-helpers/server/crud
and marked the old one as deprecated. I decided it was a good time to move it to its own entrypoint anyways, and not break old clients when I can avoid it
also there's a Stack post now: https://stack.convex.dev/crud-and-rest that lightly touches on it
I worked on a project over the summer for a client using Convex, and have just started to pick things back up after a few months of low-to-no activity. After updating deps, I seem to have some odd TS error blocking builds & updates.
All of my CustomQueries are incompatible with the CRUD helper. Am I missing something obvious?
Here's the error:
I made these dep updates with Convex:
Am I missing something obvious?
Edit: It was late, adding some additional color to the problem.
Here is my custom query:
And here is where the error shows up (on line 3. If I replace authQuery with the convex-generated query func, the error moves to line 4):