Closed kranthicodes closed 1 year ago
So @kranthicodes @t8 I tested these functions locally and they work as expected!
I have a few suggestions though:
The functions take in
query
and optionalfilters
as inputs.
- The query needs to be defined on the users end, but giving them the option to select from preexisting query structures would lower the barrier to using the GQL features.
- On the other hand, if we keep only user defined queries as the default, then the users might not end up using the filters at all (I am however, a supporter of the filters)
- Going a step further, I feel we should predefine some optional filters like
txnID
,tags
, etc. for the commonly searched option along with some predefined query structures to make querying easy.Alternatively, we can consider drawing inspiration from
ArDB
and completely take away the need for users to write any GQL.
Here is their pkg: https://www.npmjs.com/package/ardb.
The GQL syntax could be handled entirely on the backend.
This could also be something that we could add analogous to the functions Sai has created so that newbies have this option but veterans can use the custom options.
This would make sure that new users can quickly get started with querying on Arweave (like the primary goal of
arweavekit
)While also leaving way for expert users who like to have their options.
We agreed to implement further abstraction down the line.
Summary
This PR adds support to query GraphQL endpoint of selected gateway and query Transactions data via GraphQL endpoint with the help of newly introduced methods
queryGQL
,queryTransactionsGQL
,queryAllTransactionsGQL
.queryGQL
will take in a valid Arweave GraphQL query with supported filters and return a raw GQL response.queryTransactionsGQL
will take in a valid Arweave GraphQL query in a suggested format so that consumer can utilize cursor based pagination support provided by this method.queryAllTransactionsGQL
will take in a valid Areave GraphQL query in a suggested format and iteratively fetches all transactions then return it to the consumer.These methods pre-validates user's supplied query by parsing it into AST and further using
validate
method fromgraphql
package. With this validation, we can make sure to catch silly mistakes or invalid query that is not as per schema.Tests
Added unit tests for both of the methods covering common scenarios
Further notes