Filter an array of references

My advice is to try to get to a query that looks like the following. If this is way off, then I am super sorry that I am missing what you are going for. Sharing how you want to write the client query would be helpful then.

{
  findUserByID(id: "1234") {
    memberOf {
      data {
        ladder {
          rankingName
          rankingDesc
        }
      }
    }
  }
}

This should be possible without any UDFs or extra custom resolvers.

Update schema to

type User {
  active: Boolean!
  username: String!
  description: String
  email: String
  mobile: String
  ownerOf: [Ranking!]! @relation(name:"ownerranking")
  memberOf: [Player!]! @relation(name: "playerinranking")
}

type Player {
  active: Boolean!
  rank: Int!
  ladder: Ranking!  @relation # add the relation Directive
  playerInfo: User! @relation(name: "playerinranking")
  challenger: Player @relation (name: "playerchallenger")
}

type Ranking {
  active: Boolean!
  rankingname: String!
  rankingdesc: String
  player: [Player] @relation # add the relation
  owner: User! @relation(name:"ownerranking")
}

I did nothing but upload this schema and I could create this query in the playground:

You said (before edit) that you want to get the owned ranking as well as the members’ ranking. That should all be possible in a single query.

Otherwise, I suspect you are making multiple queries or at least invoking multiple top level queries with the same User ID provided.

Maybe calling at different times makes sense. If you are working with a cache, it can be super helpful to fetch data from a common endpoint, e.g. findUserByID and provide different fragments for when you want more involved data.

1 Like