feat: import pg-aggregates plugin with Constructive adaptations#1067
Merged
pyramation merged 188 commits intomainfrom May 9, 2026
Merged
feat: import pg-aggregates plugin with Constructive adaptations#1067pyramation merged 188 commits intomainfrom
pyramation merged 188 commits intomainfrom
Conversation
RFC: Add support for aggregating over computed columns
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7. - [Release notes](https://github.com/isaacs/ini/releases) - [Commits](npm/ini@v1.3.5...v1.3.7) Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [ws](https://github.com/websockets/ws) from 5.2.2 to 5.2.3. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](websockets/ws@5.2.2...5.2.3) --- updated-dependencies: - dependency-name: ws dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6. - [Release notes](https://github.com/substack/minimist/releases) - [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6) --- updated-dependencies: - dependency-name: minimist dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](chalk/ansi-regex@v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: ansi-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Benjie Gillam <benjie@jemjie.com>
For deterministic tests in different timezones Fixes #79 Co-authored-by: Benjie Gillam <benjie@jemjie.com>
Co-authored-by: Benjie Gillam <benjie@jemjie.com>
* Remove imports from graphile-config/graphile-build * Add more peer deps
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Adapt the imported @graphile/pg-aggregates v5 sources for Constructive's
codebase conventions and custom connection-filter fork.
Changes from upstream:
- Build system: yarn/tsc → pnpm/makage with CJS+ESM outputs
- Remove upstream config files (.yarn, .yarnrc.yml, .eslintignore,
.prettierrc.js, .jest-babel-transform.js, jest.config.js, etc.)
- Remove upstream test files (depend on yarn/jest infrastructure)
- Imports: Replace subpath exports (postgraphile/grafast,
graphile-build-pg/@dataplan/pg) with direct package imports
for moduleResolution: node compatibility
- FilterRelationalAggregatesPlugin: Read from $where._manyRelation
(our ConnectionFilterBackwardRelationsPlugin) instead of upstream's
$where.extensions.pgFilterRelation
- Plugin ordering: before ConnectionFilterArgPlugin (our fork's name)
- Field naming: Aggregate sub-filter field renamed from 'filter' to 'where'
- Version: Inline const version instead of require('../package.json')
- Remove .js extensions from local imports
- Add PgConditionExtensions augmentation for pgFilterAttribute
- Add graphile-connection-filter and grafast as peer dependencies
- Wire PgAggregatesPreset into ConstructivePreset in graphile-settings
- Update schema snapshots in graphql/test and graphql/server-test
Provides: aggregates field on connections (sum, avg, min, max, stddev,
variance, distinctCount), groupedAggregates with groupBy + having,
orderBy relational aggregates, filter by relational aggregates.
Per-table opt-out via @behavior -aggregates smart tag.
f0bfbff to
c0fd7f7
Compare
Tests cover: - Basic aggregates (sum, average, min, max, distinctCount, stddev, variance) - Grouped aggregates (groupBy position, team, season) - Having clause (filter groups by sum, average thresholds) - Relational aggregates (orderBy child sum/average, filter parents by child aggregates) - Schema introspection (connection fields, aggregate types, GroupBy enum, Having input, orderBy enum)
Add tests following patterns from connection-filter and other plugins: - Edge cases: NULL handling, pagination+aggregates, multiple agg functions, empty having results, orderBy aggregate with LIMIT - Aggregates with where pre-filter: filtered rows, filtered groups, season - Multi-key groupBy: two-key grouping, multi-key having - Behavior opt-out: verify -resource:aggregates hides fields per-table - Schema introspection: MatchAggregates, HavingInput stddev/variance fields
Remove PgAggregatesPreset from the default extends array so aggregates are opt-in. Users can enable by adding PgAggregatesPreset to their own preset extends (import from graphile-pg-aggregates). Update schema snapshots to remove aggregate types from default schema.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Import pg-aggregates v5 into the Constructive monorepo with full upstream git history preserved (181 commits), adapted to Constructive conventions (pnpm/makage, single quotes, our connection-filter fork).
Disabled by default —
PgAggregatesPresetis NOT included inConstructivePreset. Users opt in by adding it to their own preset'sextendsarray. This supports future per-database feature toggling (e.g. pro tier).Commit structure:
git subtree add(no--squash) preserving all upstream historygraphile-testframeworkPgAggregatesPresetfromConstructivePreset, updates snapshotsKey adaptation:
FilterRelationalAggregatesPluginrewritten to use$where._manyRelation(our fork) instead of upstream's$where.extensions.pgFilterRelation.Review & Testing Checklist for Human
FilterRelationalAggregatesPluginadaptation — this is the riskiest change. Checksrc/FilterRelationalAggregatesPlugin.tslines 40-53 against your connection-filter fork'sConnectionFilterBackwardRelationsPlugin.tsto confirm the_manyRelationshape matches.allTeams(where: { playersByTeamId: { aggregates: { sum: { goals: { greaterThan: "20" } } } } })against a production-like schema after opting in.git log --follow graphile/graphile-pg-aggregates/src/index.tsand confirm all 181 upstream commits are visible.Notes
PgAggregatesPresetto the preset extends:import { PgAggregatesPreset } from 'graphile-pg-aggregates'sum(int)returnsbigintin PostgreSQL, which GraphQL represents as a string — filter values must be strings (e.g.,greaterThan: "20")@behavior -aggregatessmart tagLink to Devin session: https://app.devin.ai/sessions/a233256611174c5fa1e38e35807cd661
Requested by: @pyramation