Open scientistnik opened 5 years ago
I think it would require a lot of effort for very little savings in bandwidth. Probably not worth the trouble. Or do you see any other significant advantages?
We've discussed this in UI team before, but as a separate setup (e.g. apollo) combined with an API proxying (and possibly caching) server
@pmconrad you right, it don't have significant advantages. Convenience only.
For example, we may define Account
and Asset
GraphQL types:
type Account {
id: String!
name: String!
registrar: String!
balances: [AssetAmount!]!
...
}
type Asset {
id: String!
symbol: String!
precision: Int!
holders(start: Int!, limit: Int!):[Account!]!
...
}
AssetAmount
is
type AssetAmount {
asset: Asset!,
amount: Int!
}
Now, we may send one request for get all information what we need:
query {
account(id: "1.2.440272") {
id
name
balances {
amount
asset {
symbol
holders(start: 0, limit: 10) {
id
name
}
}
}
}
}
If we define several types for market data, almost all information can get from one query!
query {
market(base: "BTS", quote: "USD") {
ticker {
baseVolume
quoteVolume
latest
...
}
history {
...
}
order(limit: 10) {
...
}
orderBook(limit: 5) {
...
}
}
}
Who is "we" in the example above? The client? Or is this implemented in the plugin you're proposing?
Are you talking about defining a GraphQL-based API and providing an implementation for it, or is there a ready-made generic GraphQL server that would have to interface with our internal database?
A generic API where the client specifies what and how much it wants is dangerous because it opens up new DoS attack vectors. OTOH if only predefined queries are allowed (and have to be implemented manually one by one) I still don't see significant advantages over our current API.
What you think about implement GraphQL plugin to bitshares-core?
GraphQL allow make requests for data you need. For example, if I need get orders and balances of account. I call:
I get:
But, I need only
balances
andlimit_orders
. In GraphQL: