Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
7293dbf
Initial commit
benjie Mar 10, 2019
d7def1a
Import example plugin
benjie Mar 10, 2019
9e9609b
Working
benjie Mar 10, 2019
19ed65e
Aggregates as fields
benjie Mar 10, 2019
a271a59
Add initial support for aggregating over computed columns
dwwoelfel Apr 27, 2019
26080b9
Merge pull request #1 from dwwoelfel/computed-columns
benjie Feb 3, 2021
516b6fe
Upgrade all dependencies
benjie Feb 3, 2021
c2a524b
Bump ini from 1.3.5 to 1.3.7
dependabot[bot] Feb 3, 2021
23ee1b8
Merge pull request #3 from graphile/dependabot/npm_and_yarn/ini-1.3.7
benjie Feb 3, 2021
1bea9ff
feat: aggregates overhaul (#4)
benjie Feb 15, 2021
ae9b419
chore: remove debugging logs
benjie Feb 15, 2021
477fce2
0.0.1
benjie Feb 15, 2021
81b244b
More examples in README
benjie Feb 15, 2021
8c2acd1
0.0.2
benjie Feb 15, 2021
9019c20
feat: filter by aggregates in postgraphile-plugin-connection-filter (#8)
benjie Apr 15, 2021
9c3763d
0.0.3
benjie Apr 15, 2021
cda9f2d
fix: support aggregates filters without filter (#9)
benjie Apr 16, 2021
c8dd0f9
chore: add a view for testing (#10)
benjie Apr 16, 2021
cceccbb
0.1.0
benjie Apr 16, 2021
81fc143
chore(deps): bump hosted-git-info from 2.7.1 to 2.8.9 (#14)
dependabot[bot] May 10, 2021
b9c8e95
chore(deps): bump glob-parent from 5.1.1 to 5.1.2 (#15)
dependabot[bot] Jun 11, 2021
68a979a
chore(deps): bump normalize-url from 4.5.0 to 4.5.1 (#16)
dependabot[bot] Jun 11, 2021
34d4485
chore(deps): bump minimist from 1.2.0 to 1.2.5 (#17)
dependabot[bot] Jun 11, 2021
86e05f1
chore(deps): bump ws from 5.2.2 to 5.2.3 (#18)
dependabot[bot] Jun 11, 2021
16c9bfe
docs: fix typo in README (#19)
rattrayalex Jun 29, 2021
e2fe61e
chore(deps): bump path-parse from 1.0.6 to 1.0.7 (#22)
dependabot[bot] Aug 11, 2021
9669145
docs: add better grouping derivative examples (#24)
benjie Aug 24, 2021
f77b174
fix(docs): we don't support grouping by computed column
benjie Jan 6, 2022
8f051bf
chore(deps): bump minimist from 1.2.5 to 1.2.6 (#31)
dependabot[bot] Apr 15, 2022
6605ba3
chore(deps): bump ansi-regex from 4.1.0 to 4.1.1 (#32)
dependabot[bot] Apr 15, 2022
36b6fec
chore(deps): bump moment from 2.24.0 to 2.29.2 (#30)
dependabot[bot] Apr 15, 2022
6538a3e
Convert first file
benjie Nov 28, 2022
4c01ebc
Upgrade deps
benjie Nov 28, 2022
f58e29c
tsc shouldn't lint
benjie Nov 28, 2022
0b3ad2a
Overhaul inflection
benjie Nov 28, 2022
36cb12d
Export as preset
benjie Nov 28, 2022
22e726a
Loads of syntax changes
benjie Nov 28, 2022
7898c01
Fix plugin 2
benjie Nov 28, 2022
7be8181
More fixes
benjie Nov 28, 2022
b164e25
More progress
benjie Nov 28, 2022
385b775
More syntax transform
benjie Nov 29, 2022
96db121
Another file 'fixed'
benjie Nov 29, 2022
039c086
More 'fixes'
benjie Nov 29, 2022
93b358b
More faff
benjie Nov 29, 2022
96fb755
Disable last plugin
benjie Nov 29, 2022
d6c275e
DROP THIS COMMIT
benjie Nov 29, 2022
e665548
Fixes
benjie Nov 29, 2022
bcefbe3
First few working aggregates
benjie Nov 29, 2022
ca6bed9
Computed column aggregate
benjie Nov 29, 2022
ed0549a
Grouped aggregates working
benjie Nov 30, 2022
aae5b0d
Having conditions working
benjie Nov 30, 2022
5f0585f
Having over computed
benjie Nov 30, 2022
18ead7e
Tidy computed column expressions
benjie Nov 30, 2022
f59302f
Order bys
benjie Nov 30, 2022
5fbba1b
No need to add oids
benjie Dec 1, 2022
762dff9
Make recoverable
benjie Dec 16, 2022
c827cab
Upgrade deps to V5
benjie Jan 12, 2023
f9eaecf
v0.2.0-0.0
benjie Jan 12, 2023
ed271d9
Fix bug with missing aggregates causing schema build to fail
benjie Feb 1, 2023
690b255
Clear the '{}' scourge
benjie Feb 1, 2023
2a3950c
0.2.0-0.1
benjie Feb 1, 2023
bf969af
Upgrade deps
benjie Feb 17, 2023
0ce8379
Remove duplicate graphql
benjie Feb 17, 2023
a21e84f
Plugins provide aggregates
benjie Feb 17, 2023
e9d29f4
V5 executor
benjie Feb 17, 2023
1a95f6c
Generate types for aggregate filtering (no plans yet)
benjie Feb 17, 2023
99c1c8f
Working
benjie Feb 17, 2023
597e4df
Remove old resolve code
benjie Feb 17, 2023
c55826b
Rename inflector
benjie Feb 17, 2023
e081380
Upgrade deps
benjie Feb 20, 2023
bddca5a
Fix bad import
benjie Feb 20, 2023
f9f38e4
0.2.0-0.2
benjie Feb 20, 2023
c5e1b97
Freshen yarn.lock
benjie Mar 8, 2023
56f43eb
Fix JSON double-parse bug
benjie Mar 8, 2023
c0484cb
Fix various lint errors and a couple ordering bugs
benjie Mar 8, 2023
5305b37
0.2.0-0.3
benjie Mar 8, 2023
f4087d1
Update deps
benjie Apr 18, 2023
2199d7c
Remove unnecessary deps
benjie Apr 18, 2023
167b6b7
Deprecated option
benjie Apr 18, 2023
a2a71f1
Migrate to new APIs
benjie Apr 18, 2023
b4058c3
Update config to use latest names
benjie Apr 18, 2023
ffb3b43
Upgrade V5
benjie Apr 18, 2023
5619088
Dedupe
benjie Apr 18, 2023
cb1abee
Upgrade to V5-1.1
benjie Apr 18, 2023
15df29b
0.2.0-1.0
benjie Apr 18, 2023
2945f6b
Rename 'source' -> 'resource'
benjie May 12, 2023
8095580
Fix resource.source -> resource.from
benjie May 12, 2023
c733a58
Update deps
benjie May 12, 2023
eae2a1f
0.2.0-alpha.0
benjie May 12, 2023
ffb5870
Make graphile-build, graphile-build-pg and graphql optional peerDeps
benjie May 20, 2023
05b6f8d
Migrate to new behavior system
benjie Jun 9, 2023
5518e76
Update dependencies
benjie Jun 12, 2023
09f2615
0.2.0-alpha.1
benjie Jun 12, 2023
f45e5f7
Update dependencies
benjie Jul 5, 2023
56a1431
Replace imports with build references
benjie Jul 5, 2023
a442f98
0.2.0-alpha.2
benjie Jul 5, 2023
09a1b16
Upgrade to latest releases
benjie Jul 8, 2023
c90b973
Adjust to latest API
benjie Jul 8, 2023
73d7b5b
0.2.0-alpha.3
benjie Jul 8, 2023
22966e7
Don't import from grafast
benjie Jul 8, 2023
dc186dd
Install linting
benjie Jul 8, 2023
69afc25
Add .js to imports
benjie Jul 8, 2023
f63522a
Lint fixes
benjie Jul 8, 2023
f4999cd
0.2.0-alpha.4
benjie Jul 8, 2023
d3f4b20
Upgrade deps
benjie Jul 13, 2023
bcfb043
Fixes for latest releases
benjie Jul 13, 2023
23be20d
Add missing file
benjie Jul 13, 2023
6a13d31
0.2.0-alpha.5
benjie Jul 13, 2023
52973ab
Update dependencies
benjie Aug 2, 2023
bd26916
Add explicit TypeScript types for some unknown reason
benjie Aug 2, 2023
27c92f6
0.2.0-beta.0
benjie Aug 2, 2023
9c6b4f0
0.2.0-beta.1
benjie Aug 2, 2023
2028283
Move type detection logic into fields callback
benjie Aug 24, 2023
5ae7189
0.2.0-beta.2
benjie Aug 24, 2023
9753c81
Explicit types
benjie Sep 15, 2023
db11ed5
Fix application of groupBy in groupedAggregates
benjie Sep 15, 2023
f0201e0
0.2.0-beta.3
benjie Sep 15, 2023
66847d1
Option to disable aggregates by default and for specific tables (#49)
eugeneduda Oct 11, 2023
bd374bb
Fix #53: aggregate keys should be nullable to allow grouping by nulla…
benjie Oct 11, 2023
b61c601
Fix #52: export 3 more types
benjie Oct 11, 2023
975eefb
0.2.0-beta.4
benjie Oct 11, 2023
2b5f52f
feat: add support for interval aggregation (#58)
Codykilpatrick Jan 23, 2024
0bbdf8e
0.2.0-beta.5
benjie Jan 23, 2024
7d79cd9
Make this plugin EXPORTABLE (#64)
nckswt May 14, 2024
39418a7
Clean command
benjie Jan 29, 2024
e18ec84
Enable control of which fields get added to the schema via behaviors …
benjie May 15, 2024
2905741
0.2.0-beta.6
benjie May 15, 2024
a6842b7
Upgrade
benjie Oct 7, 2024
5e134c6
Upgrade filter plugin
benjie Oct 7, 2024
18ce906
Adjust to new behavior system
benjie Oct 7, 2024
53fc194
Fix more behaviors
benjie Oct 7, 2024
107d780
Upgrade deps
benjie Oct 7, 2024
d6153ea
0.2.0-beta.7
benjie Oct 7, 2024
fbf577c
Basic jest setup
benjie Mar 5, 2025
36ee138
Fix TS setup so test files can import from package exports
benjie Mar 5, 2025
8ed954e
Add test that schema generates
benjie Mar 5, 2025
8755b89
Various minor typescript fixes
benjie Mar 5, 2025
534c73b
Use a shared config with dev mode
benjie Mar 5, 2025
ea791a5
Add more tests from the README
benjie Mar 5, 2025
c2a30be
Restore grouped aggregates by not requiring groupBy to support orderBy
benjie Mar 5, 2025
1ae6954
Build before running test
benjie Mar 5, 2025
7b27ea9
Add groupBy aggregates
benjie Mar 5, 2025
6389758
Snapshot errors and data separately and don't snapshot plan
benjie Mar 5, 2025
98717ab
Alphabetic ordering of errors/result/sql
benjie Mar 5, 2025
abde805
Update snapshot to not include raw plan
benjie Mar 5, 2025
59efcfd
Disable the index behaviors plugin
benjie Mar 5, 2025
0cab93e
Partially revert "Restore grouped aggregates by not requiring groupBy…
benjie Mar 5, 2025
1216196
Tweak default entity behaviors
benjie Mar 5, 2025
b880ebc
Much larger schema
benjie Mar 5, 2025
3606e81
Upgrade deps
benjie Mar 5, 2025
4b6a1db
Fix types
benjie Mar 5, 2025
8e3d4dc
Add indexes
benjie Mar 5, 2025
79d4b7f
Update snapshot from latest PostGraphile
benjie Mar 5, 2025
a8568d2
Add support for computed columns
benjie Mar 5, 2025
e732929
Computed column
benjie Mar 5, 2025
a5b462e
Create test snapshots
benjie Mar 5, 2025
fb5a2e9
Make TypeScript happy again
benjie Mar 5, 2025
8a96e6e
Track the codec of groupBy so it can be used for output
benjie Mar 5, 2025
0d1c3fc
Allowed changes to SQL and values
benjie Mar 5, 2025
9e779ca
Upgrade to latest postgraphile
benjie Mar 25, 2025
a6a3084
item might be null
benjie Mar 25, 2025
a7609c4
orderBy comes later
benjie Mar 25, 2025
9161908
Lint fixes
benjie Mar 25, 2025
3037f26
Update to latest PostGraphile beta
benjie Mar 25, 2025
1cd722e
0.2.0-beta.8
benjie Mar 25, 2025
473021a
Bump dependencies
benjie Oct 28, 2025
471732c
Fix types
benjie Oct 28, 2025
0239037
Update snapshots
benjie Oct 28, 2025
71147d7
0.2.0-rc.1
benjie Oct 28, 2025
9bd393d
Yarn v4
benjie Nov 5, 2025
1279224
More yarn config
benjie Nov 5, 2025
f5cab07
New yarn lockfile
benjie Nov 5, 2025
e161104
Ignore yarn stuff
benjie Nov 5, 2025
263aa38
Upgrade ESLint to v8 with typescript-eslint v8 and migrate config (#83)
faridnsh Nov 5, 2025
3c198a0
Set test db connection to UTC (#82)
faridnsh Nov 5, 2025
3d715a4
Improve exports (#89)
benjie Feb 23, 2026
e0c84be
Update to RC9 changes and improve graphile-export code size (#90)
benjie Feb 25, 2026
328898e
Update yarn.lock
benjie Feb 25, 2026
2ca3dbe
0.2.0-rc.2
benjie Feb 25, 2026
eeeeed1
Update README for PostGraphile v5 config (#92)
benjaie Mar 25, 2026
3975026
Fix type-only imports to be so (#93)
benjie Mar 27, 2026
8c4b009
Add 'graphile/graphile-pg-aggregates/' from commit '39750263edc3c1a01…
pyramation May 7, 2026
c0fd7f7
feat: adapt pg-aggregates for Constructive conventions
pyramation May 7, 2026
e1b7014
test: add pg-aggregates tests using graphile-test framework
pyramation May 7, 2026
59b4292
Merge remote-tracking branch 'origin/main' into feat/pg-aggregates-pl…
devin-ai-integration[bot] May 8, 2026
6ccef2a
test: expand pg-aggregates test suite (20 → 35 tests)
pyramation May 8, 2026
be75f3e
ci: retry integration tests (tar EOF on artifact download)
pyramation May 8, 2026
d007344
feat: disable PgAggregatesPreset by default in ConstructivePreset
pyramation May 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions graphile/graphile-pg-aggregates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dist
node_modules

# yarn stuff
.yarn/*
!.yarn/releases
!.yarn/releases/*
!.yarn/plugins
!.yarn/plugins/*
!.yarn/patches
!.yarn/patches/*
70 changes: 70 additions & 0 deletions graphile/graphile-pg-aggregates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# graphile-pg-aggregates

<p align="center" width="100%">
<img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
</p>

<p align="center" width="100%">
<a href="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml">
<img height="20" src="https://github.com/constructive-io/constructive/actions/workflows/run-tests.yaml/badge.svg" />
</a>
<a href="https://github.com/constructive-io/constructive/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
<a href="https://www.npmjs.com/package/graphile-pg-aggregates"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/constructive?filename=graphile%2Fgraphile-pg-aggregates%2Fpackage.json"/></a>
</p>

PostGraphile v5 aggregate plugin for the Constructive monorepo.

Adds aggregate support to PostGraphile connections:

- **Aggregates:** `sum`, `avg`, `min`, `max`, `stddevSample`, `stddevPopulation`, `varianceSample`, `variancePopulation`, `distinctCount`
- **Grouped aggregates:** `groupedAggregates(groupBy: [...], having: {...})` on connections
- **Order by aggregates:** Order parent connections by aggregates on related tables
- **Filter by aggregates:** Filter parent connections by aggregate values on related tables (via connection-filter integration)
- **Custom aggregates:** Register your own aggregate functions via the `pgAggregateSpecs` build extension
- **Smart tags:** `@behavior -aggregates` to disable per-table

> **Origin:** Forked from [`@graphile/pg-aggregates`](https://github.com/graphile/pg-aggregates) (v5 branch) by Benjie Gillam. Adapted for the Constructive connection-filter fork and build system.

## Usage

```typescript
import { PgAggregatesPreset } from 'graphile-pg-aggregates';

const preset: GraphileConfig.Preset = {
extends: [
PgAggregatesPreset,
],
};
```

Or via the `ConstructivePreset` which includes it automatically:

```typescript
import { ConstructivePreset } from 'graphile-settings';
```

## Example Query

```graphql
{
allOrders {
aggregates {
sum { total }
avg { total }
distinctCount { status }
}
groupedAggregates(groupBy: [STATUS]) {
keys
sum { total }
}
}
}
```

## Per-Table Opt-Out

Disable aggregates on a specific table via smart tags:

```sql
COMMENT ON TABLE my_table IS E'@behavior -aggregates';
```
Loading
Loading