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

feat: add nested entity filters #247

Merged
merged 3 commits into from
Sep 6, 2023
Merged

feat: add nested entity filters #247

merged 3 commits into from
Sep 6, 2023

Conversation

Sekhmet
Copy link
Contributor

@Sekhmet Sekhmet commented Sep 5, 2023

Depends on #246

This PR adds support for filtering entities by their subentities, for example following query becomes now possible:

{
  spaces (where: { metadata_: { name_contains: "Shadow DAO"}}) {
    id
    metadata {
      id
      name
      executors
      executors_types
    }
    voting_delay
  }
}

Test plan

Test against snapshot-labs/sx-api#181

@Sekhmet Sekhmet self-assigned this Sep 5, 2023
fields: {}
};
const getWhereType = (type: GraphQLObjectType<any, any>): WhereResult => {
const name = `${type.name}_filter`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Normalized filter name to match TheGraph.

@bonustrack
Copy link
Contributor

bonustrack commented Sep 5, 2023

Awesome, this is a great feature. I tried and it seem to work well, I have just these 2 issues:

When I try to query the sub field "id" it will fail with this error:
image
I've tested on TheGraph a similar query and it works (they keep "id" filter in the sub entity "where").

Also when I try to query a sub entity using a required field as filter it fail. Here is my schema:

...
type User {
  id: String!
  name: String
  about: Text
  discussion_count: Int! # required field
  vote_count: Int! # required field
}
...

Here is the query and response I get:
image

Without this feature I imagine we wouldn't be able to do things like search on proposals on SX-UI, now I understand why you were looking on adding metadata directly in the Space entity level. It's great that you take that different approach, it will make it easier to integrate on UI as we can keep same format with the subgraph APIs.

Base automatically changed from sekhmet/same-block to master September 6, 2023 07:15
Copy link
Contributor

@bonustrack bonustrack left a comment

Choose a reason for hiding this comment

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

tACK

@Sekhmet Sekhmet merged commit 9a9eb46 into master Sep 6, 2023
1 check passed
@Sekhmet Sekhmet deleted the sekhmet/nested-filter branch September 6, 2023 13:17
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.

2 participants