Is there a way to do delegateToSchema but expose child fields on root level only?

Viewed 26

The parent service gives me a response like this:

Notification {
  id
  TWid
}

Now I send TWid to child service to get other fields like title, body, etc. I’m able to resolve a field to child service so that I’m able to query something like this:

Notification {
  id
  data {
    title
    body
  }
}

But, I want to be able to query like:

Notification {
  id
  title
  body
}

Is it possible to do this without explicitly resolving for each field? Basically I want to automatically resolve all fields which are not there in the parent schema to child schema.

1 Answers

Doing something like this would be inherently against the schema-based design architecture that makes GraphQL consistent, so my recommendation is to re-visit your schema design as that seems like where the scope of this issue is arising.

You could use a custom directive to accomplish this, it'd lead to inconsistent results with your schema though and would be an anti-pattern for GQL schema design.

Related