Open danielbate opened 2 months ago
In #3047 I reused a lot of what we already have in the SDK to create a custom query, we could do something similar but more flexibly. Have a public function on the provider that takes a document and variables and passes the whole thing to requester, similarly to how we already build our operations.
provider.operations
, is currently a public property.provider.operations
PrivateTwo proposed alternatives for SDK consumers:
Auto-generate Their Own Clients
Implement Ad-hoc Type-safe Queries
provider.client.query('chain', {
name: true,
consensusParameters: {
chainId: true
}
});
The current structure of the SDK's GraphQL client presents a barrier to query optimization. While potential solutions have been identified, implementation remains complex and resource-intensive. Further research and development may be necessary to find a balance between maintaining backwards compatibility and enabling more efficient query structures.
Any thoughts on this @FuelLabs/frontend?
graphql-zeus looks really promising and might be the library that would enable both this and #1570 in one go.
Currently we interact with GraphQL endpoints supplied by the node via wrapped operations provided by
graphql-codegen
, these are then exposed to SDK consumers via wrapped provider functions (Provider.getVersion()
,Provider.getBlockNumber()
etc). This potentially restricts the information we are providing to consumers or means they have to go around the SDK to query the node. We should provide a way for consumers to submit their own custom queries.Potential implmentation in
Provider