Skip to content

Query help: filter inside relationships without returning data #76

@molexx

Description

@molexx

Say I want to find all Humans who have a relationship with a Droid which appeared in A New Hope.
The README has this:

query {
    Humans {
        select {
            name
            favoriteDroid(where: {appearsIn: {IN:[A_NEW_HOPE]}}) {
            	name
          	}
        }
    }
}

Which returns:

{
  "Humans": {
    "select": [
      {
        "name": "Luke Skywalker",
        "favoriteDroid": {
          "name": "C-3PO"
        }
      },
      {
        "name": "Darth Vader",
        "favoriteDroid": {
          "name": "R2-D2"
        }
      }
    ]
  }

but, I just want the Humans. I don't want any info on the Droids. Sure, it works, I can just look at the top-level Humans but there's a load of nested JSON I don't want which will get created, sent over the network and parsed. (In our real db this is much bigger!)
In the query above I have to provide at least one Droid field - either empty braces or removing the braces fails graphiql's schema validation.

Am I missing a way to do this?

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions