9

I'm looking for a way of accessing the subfield of query argument (object) without passing it as a separate argument. Here is the detailed case which explains why I need this. I have the following schema:

type Query {
  users(input: getUsersInput!):[User]
}
type User {
  _id: ID! 
  name: String!
  isAdmin(platformId: ID!)
}
type getUsersInput {
  platformId: ID!
  search: String
  #...some other query params
}

So now I want to query users for of specific platform and check if they are admins. Something like that:

query getUsers($input: getUsersInput!) {
  users(input: $input) {
    _id
    name
    isAdmin(platformId: $input.platformId)
  }
}

However referencing platformId with $input.platformId gives an error.

I can pass platformId into the query as an extra argument, but I'd like to avoid. I guess the solution might be in several directions:

  1. There is another syntax/way of getting access to the subfield of a query argument. However, I haven't seen any example of it.
  2. Build a schema or queries another way.

Would be happy to get any help and thoughts on this.

0 Answers0