Skip to content

GraphQL aggregation docs misleading #3670

Description

@flof

The documentation for data-api-builder GraphQL aggregations contains examples that seem not to work. Neither with 1.x nor with 2.x versions of data-api-builder.

For example: This is the first query in the docs:

{
  books(
    groupBy: { fields: ["year"] }
  ) {
    items {
      year
    }
    aggregates {
      pages {
        sum
        average
        min
        max
      }
    }
  }
}

This query doesn't work. It returns an error saying that "groupBy" is not valid here.

But i found out that this works:

{
  books {
    groupBy(fields: [year]) {
        fields {
            year
        }
        aggregations {
            sum(field: pages)
        }
    }
}

I learned about this query syntax in an example in the source code .

I tested with the Docker versions 1.7.93 and 2.0.8 of data-api-builder and got the same results on both versions.

Is there a mismatch between documentation and implementation? Or do i look at the wrong documentation?

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No fields configured for Bug.

Projects

Status
Todo

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions