9 Replies
In general, the benefit of using Confect is that it allows you to use Effect with Convex. As for why you might want to use Effect, I'd recommend https://effect.website/ or https://effect.website/docs/getting-started/why-effect/.
A couple of the cool, unique features of this integration are:
- The ability to define your Convex database schema using Effect's Schema module, which is similar to Zod. This means that you can define constraints like "this must be a string that is between 1 and 100 characters", or do automatic decoding/encoding of
Dates (to pick only a few examples).
- The ability to define an HTTP API using Effect's HTTP API modules, which is much more fully-featured than Convex's default HTTP router, and allows you to auto-generate hosted API documentation (like Hono).
But if you're not invested in Effect, and have no interest in investing in it, it's probably not the right library for you!I feel like every few years we try to re-build Redux-sagas in some way, and that's how I see this new effect library
It's a lot more than that š
But if that's something you keep coming back to you, you definitely might appreciate what Effect has to offer!
Effect Documentation
Why Effect?
Discover how Effect transforms TypeScript programming by using the type system to track errors, context, and success, offering practical solutions for building reliable, maintainable applications.
@RJ any plans on integrating effect atom?
Iād love to, but it will have to be a post-v1 feature
@RJ sorry to ping you, but do you have any telemetry patterns with Confect?
As in Convex we end up doing a lot of subqueries due to the lack of joins, I'd love to be able to read through Effect-provided OpenTelemetry data to spot potential improvements. As we can't send any data out of queries and mutations, however, AFAIK this is not possible. We're perhaps constrained to Convex's logs?
Thanks in advance for your attention and for the great work! If this info helps, I'm not yet using Confect due to:
1. you've said it's not production ready
2. I'm not a fan of React hooks returning Effects. Perhaps my perception will change with @effect-atom gaining steam? Or it may be that I simply don't know how to work with them outside of generators/pipes š
3. I'm reluctant of adopting the Schema -> Convex/values pipeline. As I'm not clear on what you're doing under the hood, I've preferred staying with the raw v.type + lightweight zod mirrors
That said, I'm rebuilding some of your abstractions in a worse way, with less experience, so I'm glad to move over once you're confident this can be adopted in production š
Hey @hdoro; I don't right now. I think that to integrate Effect's observability features with Convex (inside queries and mutations) you'd need to schedule an action to run at the completion of each query/mutation (e.g.
scheduler.runAfter(0, internal.processTrace)) to exfiltrate this information. I'm really not very familiar with the Effect observability APIs, but I think you'd maybe need to implement your own SpanProcessor which does this for you? But either way, I think this should be possible.
This is something I'd be interested in doing with Confect, but it's not likely something I'll be able to get to very soon.
Thanks for your feedback on Confect š To your points:
1. I'd say it is production-ready (I use it in production) in the sense that it does what it advertises and is thoroughly tested, but the API is unstable, and I consider it pre-1.0 because I think it's still missing some important features. If you're ok with some major breaking changes, at least between 0.0.x and 1.x.x, and like what it currently has to offer, you could definitely get started now.
2. The React hook APIs are very naive implementations of fully end-to-end type-safe interop which will come in v1. I'm not sure that they should return Effects either š¬
3. All that happens here is that we convert the encoded side of your table Schema into a Convex validator via this function. It's not quite as complicated as it might seem. Schema.String becomes v.string(), Schema.NonEmptyString also becomes v.string(), etc. I'm happy to answer any questions you might have about this if I can (and would be glad to understand better your reluctance here in general, in case this is a point of friction/misunderstanding for other folks).Wow, thanks a ton for your answers! Scheduling an action at the end of every mutation and query just to extract telemetry data feels too heavy handed, but I may try doing this in the development branch or as defined by an environment variable to help with spotting improvements when needed š
Right now I'm behind schedule at work, so the next 3-4 weeks I won't be able to join in on polishing Confect... But I'd love to and I highly appreciate your openness and help! I'll try to get back to you when I'm done and have more time š»