In GraphQL there is only a single root Query
object. As a consequence the root object keeps growing over time.
To solve this problem you can split a root object in multiple groups:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RootQuery : ObjectGraphType | |
{ | |
public RootQuery() | |
{ | |
Name = "Query"; | |
Field<NonNullGraphType<ProductsQuery>>().Name("Products").Resolve(context => new { }); | |
Field<NonNullGraphType<CustomersQuery>>().Name("Customers").Resolve(context => new { }); | |
} | |
} |
Field<NonNullGraphType<ProductsQuery>>().Name("Products").Resolve(context => new { });
Remark: This also works for mutations and subscriptions.