graphql-rust / juniper

GraphQL server library for Rust
Other
5.72k stars 425 forks source link

Why doesn't juniper_warp::make_graphql_filter take schema: Arc<RootNode<...>>? #1135

Closed silvanshade closed 1 year ago

silvanshade commented 1 year ago

I notice that juniper_hyper::graphql takes the schema/rootnode argument as type Arc<RootNode<...>> but juniper_warp::make_graphql_filter only takes the schema as RootNode<...>.

This seems to make juniper_warp difficult to use in practice in the scenario of library integrations (e.g., a juniper-based GraphQL plugin for tauri).

In the example here this issue is side-stepped completely by creating a function schema() which returns a fresh RootNode instance.

In a library integration, however, you do not have access to the components necessary to construct a new RootNode.

It seems that juniper_warp should take the argument as an Arc<RootNode<...>> like juniper_hyper in order to avoid this problem.

Is there a reason why it is not defined this way?

tyranron commented 1 year ago

@silvanshade I don't see any. It seems that authors of the code just didn't consider this use case. A PR would be appreciated.