graphile / pg-aggregates

Aggregates for PostGraphile connections
83 stars 17 forks source link

All attributes appear in aggregates, even if disabled by behaviors #66

Closed nckswt closed 5 months ago

nckswt commented 6 months ago

Summary

Using this plugin, I wanted to disable property.created_at but it shows up in the aggregate (see screenshot) image

Using graphile behavior debug pgCodecAttribute property.created_at my final string for this property.created_at attribute is

Final string:
  -list -insert -update -delete -filterBy -orderBy -* -select -query -connection -order -base -filter -aggregates

Shouldn't it be disabled in the distinctCount aggregate?

Steps to reproduce

Use PgAggregates and set an attribute's behavior to -*.

Expected results

I would not expect that attribute to appear in the schema.

Actual results

That attribute appears in the schema.

Additional context

Discord thread

benjie commented 6 months ago

From a quick search of the codebase (v5 branch) for the word behavior, it looks like the aggregates behavior has only been implemented for resources (tables) and relations (FKs) at this time. The relevant places would need to call build.behavior.pgCodecAttributeMatches(...) and skip adding the relevant field/etc if false. Are you interested in taking that on? It could be months before I get around to it.