Back

[SOLVED] how to make function calls from flutter webapp

  • 0
  • Self Hosted
  • Flutter
  • Functions
punti_z
26 Dec, 2023, 18:18

I am working on a web app where users can create lists. I perform a bunch of validation server side with functions and currently I do this as follows

  1. Write user request to a request collection
  2. Collection triggers a function
  3. Function validates and writes to user lists collection
  4. User gets realtime update from user lists collection
  5. App updates

I want to move away from database triggering functions to making a POST request to the function directly. The examples on appwrite documentation shows server side code but not client side code (working with flutter). How am I supposed to make such a request ?

Create a function execution request ? If so how is user supposed to get response data once execution completes ?

TL;DR
User is trying to make function calls from a Flutter web app. They want to move away from using database triggers and instead make a POST request to the function directly. They are looking for guidance on how to make this request and how to get the response data once the execution completes. Solution: They can use the CreateExecution method and set the async parameter to false to ensure that the execution is processed right away and the response data is populated. They can also check out the Appwrite documentation for more information on making function calls from a Flutter app.
Drake
26 Dec, 2023, 18:35

Are you creating collections at runtime?

punti_z
26 Dec, 2023, 18:49

Not sure what you mean, which collections ? No collections are created at runtime, only documents in said collections to help trigger respective functions.

Drake
26 Dec, 2023, 18:54
punti_z
26 Dec, 2023, 19:20

Of course I have, quite a bit. The only thing I see there is to create execution but I am not sure with that how i am supposed to pass data back to the user ? From what I understand the CreateExecution will immediately return execution status and not data I might want to send back i.e., list created or failed with error etc. Not sure if I create ASYNC false execution would an await work then ? Thus wanted to ask the experts 🙂

Just to be clear I am speaking purely in a flutter context.

Drake
26 Dec, 2023, 19:51

Yes, the async parameter is what will determine whether the execution should be processed right away and have the response populated

punti_z
26 Dec, 2023, 20:17

Sounds pretty straight forward. Will need to try. Another thing to check, since like users creating lists is a very common task that will happen quite often, any possible pitfalls with a large number of async false executions being queued ?

Drake
26 Dec, 2023, 20:18

Synchronous executions don't get queued. The only thing is if your function hasn't executed successfully in a while, the runtime container may be removed so the next execution will be a cold start

punti_z
26 Dec, 2023, 20:24

Cold start is not a concern, my concern is, to quote a hypothetical extreme case, 100 synchronous requests on a 2 vcpu server. They will , I assume, be executed sequentially thus the await for a 100th request will be resolved once its executed say a minute or so later and with a response ? Accurate ?

Drake
26 Dec, 2023, 20:25

No, they're all executed concurrently (up to a certain limit) just like how create document requests don't execute sequentially

punti_z
26 Dec, 2023, 20:25

Ah understood. Thanks

punti_z
26 Dec, 2023, 20:26

[SOLVED] how to make function calls from flutter webapp

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more