-
Notifications
You must be signed in to change notification settings - Fork 438
Description
Including lifetimes on error types introduces huge overhead and greatly reduced flexibility for their use. Especially with the ? now in common use, intoing the Error type based on the Result returned by the function becomes extremely difficult when you have to preserve its lifetime.
I'm happy to write a PR myself, but want some feedback on the best place to remove it. Right now, it's simply the Token<'a>, which means juniper::parser::ParseError<'a>, which means juniper::GraphQLError<'a>, which bubbles up to every single caller. This is way too much insight into the inner workings of juniper than should exist on a public error -- I just need a nice message if there's a problem parsing, not the whole token. Right now it makes this impossible without separately mapping the error to remove it:
juniper::execute_async(
query,
None,
&RootNode::new(Query, Mutation),
&vec![(
"uuid".into(),
InputValue::scalar("04310DD5269111EAAD050242AC120003"),
)]
.into_iter()
.collect(),
&ctx,
)
.await?because now &RootNode::new(Query, Mutation) is borrowed but the await?'s result Error consumes it.
The obvious options:
- remove the
Tokencompletely and return some error info we build - clone the
Token(it already impls Clone) so we can pass back aToken<'static>instead - open to suggestions..