Nikhil Cheerla
Nikhil Cheerla
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
would we call the external service twice?
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
and then we had a handler that called this mutation and then called an external service to sign the user up for something if the result was 'new_user_created'
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
suppose you had a dummy mutation that inserted a user into a DB if the user didn't already exist ... and it returned 'new_user_created" if you had the user in the DB and 'user_already_exists' if the user wasn't already in the DB
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
ah i see, why would you run the code in handlers twice?
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
ok perfect! I think this v1 would be all we need for side effects in functions, let me know when it's live and would love to try it out, even as a beta feature
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
I think this would be pretty key for running mutations
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
for example, could we get the return value of the mutation?
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
would there be any way to determine that the mutation "succeeded" in sending the message, vs failed?
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
so suppose you have a mutation function like the one in your docs for sending a message if it is more than 10 characters:
export default mutation(({ db }, body, author) => {
if (body.length < 10) {
return "Message is not long enough!";
}
db.insert("messages", { body: body.toUpperCase(), author });
return "ok";
});
export default mutation(({ db }, body, author) => {
if (body.length < 10) {
return "Message is not long enough!";
}
db.insert("messages", { body: body.toUpperCase(), author });
return "ok";
});
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
got it
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
when a function calls a query or mutation does it get the result "immediately" or does it have to listen to the db somehow?
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
cool!
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
but I think the current design is fine otherwise
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
i'm just trying to avoid the latency of communicating between vercel -> convex functions and then convex functions -> db update -> listener on vercel
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
honestly to me it seems like the simplest API is having handler objects just like you have query and mutation objects. handlers don't have access to the convex DB or anything by default but they can call queries and mutations, and queries and mutations also return their "results" directly to the handlers as well as writing to the db
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
got it. the use-case I envision for functions with side effects is running the side effect at the end, after the mutation commits. Do you plan to support that use-case, and will it still be fast taking into mind the "caching, consistency, conflict resolution" considerations you mentioned?
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
got it. i think for our usecase webhooks are a necessity and functions with side-effects are almost a necessity, would love to know the timeline on when those would be out 😃
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
got it, but right now you have to make two hops, go through some express server hosted through vercel and then that server calls a convex mutation on the convex server?
41 replies
CCConvex Community
Created by Nikhil Cheerla on 10/16/2022 in #general
3rd party functions
got it, what about webhooks? for example, we might want a convex mutation to trigger when Twilio sends a POST request to a certain URL ... do we have to route through some self-hosted express server to do that (on Vercel or Netlify)?
41 replies