Merge multiple Juniper object definitions into a single object type.
You are building a GraphQL server using Juniper. At some point you realize that you have gigantic Query and Mutation types:
```rust
struct Query;
impl Query { async fn user(ctx: &Context, id: Uuid) -> User { // ... }
async fn users(ctx: &Context) -> Vec<User> {
// ...
}
async fn task(ctx: &Context, id: Uuid) -> Task {
// ...
}
async fn tasks(ctx: &Context) -> Vec<Task> {
// ...
}
// ...many more
} ```
You would like to split it up into multiple domain-specific files, and have e.g. all User queries in one file and all Task queries in the other. With current Juniper API, it is very hard to do, but this crate can help you.
```rust
struct UserQueries;
impl UserQueries { async fn user(ctx: &Context, id: Uuid) -> User { // ... }
async fn users(ctx: &Context) -> Vec<User> {
// ...
}
}
struct TaskQueries;
impl TaskQueries { async fn task(ctx: &Context, id: Uuid) -> Task { // ... }
async fn tasks(ctx: &Context) -> Vec<Task> {
// ...
}
}
composite_object!(Query(UserQueries, TaskQueries)); ```
Custom contexts are supported:
rust
composite_object!(Query<Context = MyCustomContext>(UserQueries, TaskQueries));
Visibility specifier for generated type is supported:
rust
composite_object!(pub(crate) Query<Context = MyCustomContext>(UserQueries, TaskQueries));
Custom scalars are currently not supported, but will be added if requested.