joey
joey3w ago

reactive vs non-reactive query from another backend service

Is there a difference between calling a reactive vs non-reactive query from another backend service? Say, FastAPI
7 Replies
ballingt
ballingt3w ago
@joey I'm not sure what you mean
joey
joeyOP3w ago
If the client is another service handling a quick API request, there's no reason to maintain a subscription. Maybe the answer to this will become apparent to me if i just look at the python SDK (I'm just getting started with using convex so pardon if it's a dumb question)
ballingt
ballingt3w ago
Ok yeah if you're running a query from a Python server, yep you'd use the Python client and also do a non-reactive query https://pypi.org/project/convex/ Is there a difference? Yes, if you subscribe then it's a stream of results that update. If you call .query(), it's just one-shot request.
joey
joeyOP3w ago
Makes sense. Thanks!
ballingt
ballingt3w ago
@joey I'm not sure I'm answering your question, but yeah I agree that on a server you may not want to subscribe
handling a quick API request, there's no reason to maintain a subscription
yep, sounds like a good case for a non-reactive query What is your question?
joey
joeyOP3w ago
You answered my questions, which were essentially "what happens if you call a reactive query from a non-reactive context" and "what are the differences in behavior of reactive vs non-reactive queries"
ballingt
ballingt3w ago
Ahhh got it, generally both are available everywhere, convex isn't aware of what's a reactive vs non-reactive context. Great point, yeah it's your responsibility to decide which you want, if you call convex_client.subscribe('queries:yourQuery', args) inside a function that you call from an HTTP server handler, the code doesn't try to figure that out, it just subscribes to that query.

Did you find this page helpful?