Skip to content

GraphQL list queries fail to load aggregates with parent filter references #379

@jechol

Description

@jechol

Code of Conduct

  • I agree to follow this project's Code of Conduct

AI Policy

  • I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Versions

  • Elixir: 1.18.3
  • Ash: 3.7.6
  • AshGraphql: 1.8.3
  • AshPostgres: 2.6.23
  • AshSql: 0.3.9

Operating system

macOS 15.6.1

Current Behavior

GraphQL list queries fail when loading aggregates that reference parent fields in their filter expressions.

Error: ERROR 42703 (undefined_column) column s0.last_read_msg_id does not exist

The generated SQL's subquery s0 doesn't include the field referenced in the aggregate filter.

Important: This ONLY affects aggregates in list queries. Everything else works:

  • Resource-level queries (read/read_one) ✅
  • GraphQL get queries ✅
  • has_many relationships with identical filters ✅

Reproduction

Full reproduction repository: https://github.com/jechol/ash-graphql-aggregate-bug

Expected: 1 failure out of 8 tests (GraphQL list query with aggregate)

The repository includes:

  • Minimal schema (Chat, Message)
  • Aggregate using parent(last_read_msg_id) in filter
  • has_many with identical filter (works fine)
  • Tests comparing all scenarios

Expected Behavior

GraphQL list queries should successfully load aggregates that reference parent fields.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions