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

Filtering on aggregates now supported via @graphile/pg-aggregates #152

Closed
benjie opened this issue Apr 16, 2021 · 5 comments
Closed

Filtering on aggregates now supported via @graphile/pg-aggregates #152

benjie opened this issue Apr 16, 2021 · 5 comments

Comments

@benjie
Copy link
Member

benjie commented Apr 16, 2021

@graphile/pg-aggregates has added integration with this plugin to enable powerful aggregate filtering (e.g. "players who have scored more than 6 goals and had less than 2 fouls in the last 6 months"); I figure it might be useful to link to this in the README, but wasn't sure where to suggest - what do you think?

graphile/pg-aggregates#8

@jcrben
Copy link

jcrben commented Apr 17, 2021

This looks like what I needed!

But without this, is there a way to filter based on totalCount? Cause that's all I need for now
image

For now I'm just doing this on the client side

@benjie
Copy link
Member Author

benjie commented Apr 17, 2021

Not currently but feel free to file an issue about it

@jcrben
Copy link

jcrben commented Apr 20, 2021

fyi I ended up accomplishing my goal of filtering the industries based their count of companies via aggregates distinctCount; query looks like the blow

    query allIndustries($first: Int) {
        allIndustries(
            first: $first
            filter: {
                companiesByIndustry: {
                    aggregates: {
                        distinctCount: { industry: { greaterThan: "0" } }
                    }
                }
            }
            orderBy: COMPANIES_BY_INDUSTRY_COUNT_DESC
        ) {
            nodes {
                name
                code
                companiesByIndustry(first: 2) {
                    totalCount
                    nodes {
                        name
                        ticker
                    }
                }
            }
            totalCount
        }
    }

@mattbretl
Copy link
Member

Awesome work! 🎉

I'm planning to move some of the huge sections of the README into separate files, and as part of that, I'll add a section with links to related plugins.

@mattbretl
Copy link
Member

Updated the README 😄

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

No branches or pull requests

3 participants