Open orbitlens opened 5 years ago
+1 on this one.
Leaving this open but I think we should use something like GraphQL as it gives you better control of query and response.
+1
+1 on using GraphQL. You could also layer it on top of horizon as a separate service but then you still end up hitting horizon API multiple times (although possibly from the same datacenter so you'd get latency benefits for the client but no benefits for single queries and consistency)
I think it's worth adding this feature to the REST API before we do a full GraphQL implementation.
The main question here is: do you need this for consistency or speed?
If the answer is consistency, it would require a rearchitecture of Horizon's web module to support running batched HTTP requests in a REPEATABLE READ
transaction. This has many implications like impact on stellar-core DB, rate limiting, good design for such API calls etc. In short: not trivial but we can run some experiments.
If the answer is speed, Horizon supports http/2 that has batching built-in so you should just use that.
Many Stellar usage scenarios require fetching up-to-date information about more than one account from Horizon. Even for such simple things like an ordinal payment, the application needs to fetch both source (to get the sequence) and destination (to check whether it exists and has the required trustline) accounts. Smart contracts and other advanced use cases may require fetching more than two accounts from the Horizon.
Proposed query format:
Example:
The result should be atomic. API should fetch current state of all requested accounts in one DB query which automatically returns consistent state despite any concurrent updates following the DB transaction isolation policy
Benefits:
/accounts
endpoint.