Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement: add filtering, sorting, and pagination to GraphQL queries #763

Merged
merged 9 commits into from
Apr 26, 2023

Conversation

ra0x3
Copy link
Contributor

@ra0x3 ra0x3 commented Apr 15, 2023

This is deekerno speaking as ra0x3. 😉

Closes #637, #656.

Changelog

  • Add arguments module for turning query arguments into the new QueryParams struct
  • Add functionality and tests for the following filter types:
    -- id: select a record by its ID
    -- and / or: combine two filters together
    -- not: negate the behavior of a filter
    -- has: select records that have non-null values for columns in list
    -- in: select records that have a value matching an element in set
    -- gt / gte / lt / lte (greater than, etc.): select records whose value satisfies the comparison condition
    -- between: select records whose value falls between the bounds of the comparison condition
  • Add sorting and pagination functionality and tests
  • Move stuff specific to GraphQL API queries to fuel-indexer-schema/db/queries.rs
  • Add additional variants to GraphQLError
  • Update documentation for GraphQL queries and new functionality
  • Added support for field aliasing in GraphQL queries
  • Add fuel-indexer-graphql and fuel-indexer-graphql-parser packages

Testing Plan

I've added extensive testing (15 new tests in total) for filtering and pagination, and unit tests have been adjusted where necessary. CI should pass.

Manual Testing

Feel free to peruse changes from the documentation PR for example queries that you can use for the block explorer indexer; there are pages for filtering and pagination as well as this page that contains a fully-featured example of all of the GraphQL querying functionality being used together (nested entities, sorting, pagination, and filtering).

@ra0x3 ra0x3 added documentation Improvements or additions to documentation P: High book big labels Apr 15, 2023
@ra0x3 ra0x3 marked this pull request as draft April 15, 2023 16:21
@deekerno deekerno linked an issue Apr 15, 2023 that may be closed by this pull request
@deekerno deekerno marked this pull request as ready for review April 19, 2023 19:27
@deekerno deekerno requested a review from a team April 19, 2023 19:27
@deekerno deekerno changed the title feature/the-graphql-update enhancement: add filtering, sorting, and pagination to GraphQL queries Apr 19, 2023
@ra0x3 ra0x3 force-pushed the feature/the-graphql-update branch 2 times, most recently from d0c8176 to 1d43beb Compare April 21, 2023 00:33
0xmovses
0xmovses previously approved these changes Apr 21, 2023
Copy link
Contributor

@0xmovses 0xmovses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks really readable and easy to reason about. I've tested things in the playground and couldn't find any bugs. We reviewed the docs already. So LGMT 🚀

deekerno and others added 5 commits April 21, 2023 15:47
Add filtering functionality to GraphQL API; add E2E tests
…ueries (#755)

* Add comments; rename to clearer variables

* Add sorting and offset-based pagination
* Add PageInfo object to queries with a limit

* Adjust tests

* Change API response to snake_case
* Add docs for GraphQL filtering and pagination

* Move QueryResponse to models module

* Address rvmelkonian feedback

* Address ra0x3 feedback
@deekerno deekerno force-pushed the feature/the-graphql-update branch 2 times, most recently from fada863 to f378267 Compare April 23, 2023 19:52
@deekerno deekerno requested a review from 0xmovses April 24, 2023 15:49
@0xmovses
Copy link
Contributor

@deekerno Just need to fix these conflicts, then this is good to go in.

@ra0x3 ra0x3 requested a review from deekerno April 26, 2023 19:19
Copy link
Contributor

@deekerno deekerno left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥷

Copy link
Contributor

@0xmovses 0xmovses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@deekerno deekerno merged commit a8cdc0a into master Apr 26, 2023
@deekerno deekerno deleted the feature/the-graphql-update branch April 26, 2023 19:43
@0xmovses 0xmovses mentioned this pull request Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
big documentation Improvements or additions to documentation P: High
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support GraphQL pagination Add filtering to GraphQL API queries
3 participants