nuwave / nuwave/lighthouse

Aggregation in pagination

Open
#1,464 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
3.5k
Forks
468
Avg merge
3h 9m
Merged PRs (30d)
2

Description

I will gladly provide a PR for this issue

What problem does this feature proposal attempt to solve?

There's no easy way to get different aggregations of columns or relations, without declaring each of them separately.

Which possible solutions should be considered?

The should be two new types; ColumnAggergation and RelationAggregation. And the generated input creates one for each column and relation, containing the relevant possible aggregations. Also to make sure it doesn't impact performance, the aggregations should be preformed only when there's a request for it.

Request Example

products{
    pagintorInfo {
       total
    }
    data {
       price
       purchases {
           id
       }
    }
    aggregation {
       price {
           min
           max
           sum
       }
       purchases {
           total
       }
    }
}

Generated Type

type ProductPagination
{
  paginatorInfo: PaginatorInfo!

  data: [Product!]!

  aggregation : ProductAggregation!
}

type ProductAggregation
{
  price: ColumnAggregation

  purchases : PurchaseRelationAggregation
}

type PurchaseAggregation
{
  payed: ColumnAggregation
}

type PurchaseRelationAggregation
{
  columns: PurchaseAggregation
  aggregation: RelationAggregation
}

type ColumnAggregation
{
  count: Int

  sum: Int

  min: Int

  max: Int

  average: Int

  mean: Int
}

type RelationAggregation
{
  count: Int
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named in the issue. Start by locating the pagination schema generation and resolver paths, then compare them with the requested GraphQL request and generated types; done means requested column and relation aggregations are available only when queried without degrading pagination performance.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, laravel, php
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.