0

My schema defines an Employee type that has 15 or so fields on it. It's then used multiple times in other areas:

type Employee {
  active: Boolean!
  name: String
  id: Int!
  ...
}

type Room {
  owner: Employee!
  delegate: Employee
}

99% of the time, I want the same three fields when returning data on an employee. So I end up writing a query like this:

query { 
  rooms {
    owner: {
      name
      id
      active
    }
  }
}

which is repetative when something has multiple employees. Is there a way to define some type of transformation so that instead I'd do something like:

query {
  rooms {
    owner: @commEmpFields
  }
}

My initial thought was to create a custom ObjectType<Employee> but then I realized that I didn't know how to map that to the query.

Gargoyle
  • 9,590
  • 16
  • 80
  • 145

0 Answers0