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

Related queries enhancement #84

Merged
merged 18 commits into from
Nov 19, 2022
Merged

Related queries enhancement #84

merged 18 commits into from
Nov 19, 2022

Conversation

karatakis
Copy link
Collaborator

@karatakis karatakis commented Oct 18, 2022

PR Info

Make related queries to receive filtering, ordering and (memory) pagination

Example: Get all customers with their address and order (order amount grater than 8 sorted by amount descending, 1st item only)

{
  customer(
    filters: { active: { eq: 0 } }
    pagination: { cursor: { limit: 3, cursor: "Int[3]:271" } }
  ) {
    nodes {
      customerId
      lastName
      email
      address {
        address
      }
      payment(
        filters: { amount: { gt: "7" } }
        orderBy: { amount: ASC }
        pagination: { pages: { limit: 1, page: 0 } }
      ) {
        nodes {
          paymentId
          amount
        }
        pages
        current
        pageInfo {
          hasPreviousPage
          hasNextPage
        }
      }
    }
    pageInfo {
      hasPreviousPage
      hasNextPage
      endCursor
    }
  }
}

Adds

  • filters on related queries 1-m
  • sorting on related queries 1-m
  • Groundwork for pagination on related queries

@karatakis karatakis force-pushed the related-queries-enchantments branch from fd9b9ae to 63de846 Compare October 26, 2022 19:08
@karatakis karatakis marked this pull request as ready for review November 7, 2022 09:23
@karatakis karatakis requested a review from billy1624 November 7, 2022 09:56
@@ -1,3 +1,4 @@
#![recursion_limit = "1024"]
Copy link
Member

Choose a reason for hiding this comment

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

I wonder where is the recursion? And why increasing the limit convince Rust compiler?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For more information about the recursion can be found here async-graphql/async-graphql#1125.

An idea is to generate a GraphQL connection node using derives

@billy1624
Copy link
Member

Hey @karatakis, could you help me resolve the merge conflict? Thanks!!

@billy1624
Copy link
Member

Hey @karatakis, I want to double check, is this ready for review?

@karatakis karatakis force-pushed the related-queries-enchantments branch from 27493e9 to 6876726 Compare November 11, 2022 14:35
@karatakis
Copy link
Collaborator Author

@billy1624 its ready

@tyt2y3
Copy link
Member

tyt2y3 commented Nov 15, 2022

Wow, that's really sophisticated querying!
We should add test cases for new features, it will tell us when it breaks someday.

@karatakis
Copy link
Collaborator Author

karatakis commented Nov 15, 2022

I have to add some test cases and fix the self ref tests because now it returns a graphql connection node

@karatakis karatakis force-pushed the related-queries-enchantments branch from 041083f to 440d7c5 Compare November 15, 2022 13:56
@tyt2y3
Copy link
Member

tyt2y3 commented Nov 17, 2022

Cool! @billy1624 can review again?

@tyt2y3
Copy link
Member

tyt2y3 commented Nov 17, 2022

Okay, may be one dump question. Is Enchanted a typo of Enhanced or is it meant to be?

Copy link
Member

@billy1624 billy1624 left a comment

Choose a reason for hiding this comment

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

Hey @karatakis, great work!! I got some refactoring. Please check

* Make RelationKeyStruct into struct with named fields

* Add RelationParams

* Fix clippy
Copy link
Member

@billy1624 billy1624 left a comment

Choose a reason for hiding this comment

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

Hey @karatakis, feel free to merge! Nice work!

@karatakis
Copy link
Collaborator Author

Okay, may be one dump question. Is Enchanted a typo of Enhanced or is it meant to be?

Typo! Its an old habit from too many RPGs in the past.

@karatakis karatakis changed the title Related queries enchantments Related queries enhancement Nov 19, 2022
@karatakis karatakis merged commit de9a935 into main Nov 19, 2022
@karatakis karatakis deleted the related-queries-enchantments branch November 19, 2022 08:36
@github-actions
Copy link

🎉 Released In 0.3.0 🎉

Thank you everyone for the contribution!
This feature is now available in the latest release. Now is a good time to upgrade!
Your participation is what makes us unique; your adoption is what drives us forward.
You can support SeaQL 🌊 by starring our repos, sharing our libraries and becoming a sponsor ⭐.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add filters on related queries
3 participants