GraphQL Schema Delegation through Declarative Programming

454 views Asked by At

I was looking at the documentation of graphql-tools, and wanted to know if we can use declarative programming model to delegate queries or mutations to sub-schemas?

https://www.graphql-tools.com/docs/schema-delegation

Specially the delegateToSchema type of call, can this done through SDL using directives?

1

There are 1 answers

0
Matthew M. On

Yes, it's possible. You can use the @delegate directive to delegate your query to the appropriate schema.

The sample below assumes you are querying for a customer. In your SDL, you might add:

type CustomerQuery
{
    customer(customerId: ID!) : Customer @delegate(schema: "CustomerServiceSchema": path: "customer(customerId: $arguments:customerId)")
}