Skip to content

Grouping ignored if grouped-by field not included in return fields #4954

Description

@ribiza

Same setup as #4951 (and possibly related).

This query groups books by genre and displays their titles:

{
  Book(groupBy: [genre]) {
    genre
    GROUP {
      title
    }
  }
}
{
  "data": {
    "Book": [
      {
        "GROUP": [
          {
            "title": "Les Misérables"
          },
          {
            "title": "Infinite Jest"
          },
          {
            "title": "1984"
          },
          {
            "title": "Lord of the Flies"
          },
          {
            "title": "Girl with Curious Hair"
          }
        ],
        "genre": "Fiction"
      },
      {
        "GROUP": [
          {
            "title": "Consider the Lobster and Other Essays"
          }
        ],
        "genre": "Nonfiction"
      },
      {
        "GROUP": [
          {
            "title": "Down and Out in Paris and London"
          }
        ],
        "genre": "Memoir"
      }
    ]
  }
}

However, remove the genre field from the top return, and all books get clumped into a single group:

{
  Book(groupBy: [genre]) {
    # genre
    GROUP {
      title
    }
  }
}
{
  "data": {
    "Book": [
      {
        "GROUP": [
          {
            "title": "Les Misérables"
          },
          {
            "title": "Infinite Jest"
          },
          {
            "title": "Consider the Lobster and Other Essays"
          },
          {
            "title": "Down and Out in Paris and London"
          },
          {
            "title": "1984"
          },
          {
            "title": "Lord of the Flies"
          },
          {
            "title": "Girl with Curious Hair"
          }
        ]
      }
    ]
  }
}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions