Clippy fixes (#1181)

This commit is contained in:
Christian Legnitto 2023-08-25 18:48:01 -04:00 committed by GitHub
parent 27430bf60c
commit 108ccf2715
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 190 additions and 200 deletions

View file

@ -112,11 +112,7 @@ where
Self: PartialEq, Self: PartialEq,
{ {
fn partial_cmp(&self, other: &ExecutionError<S>) -> Option<Ordering> { fn partial_cmp(&self, other: &ExecutionError<S>) -> Option<Ordering> {
(&self.location, &self.path, &self.error.message).partial_cmp(&( Some(self.cmp(other))
&other.location,
&other.path,
&other.error.message,
))
} }
} }

View file

@ -21,7 +21,7 @@ impl TestType {
async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F) async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
where where
F: Fn(&Object<DefaultScalarValue>) -> (), F: Fn(&Object<DefaultScalarValue>),
{ {
let schema = RootNode::new( let schema = RootNode::new(
TestType, TestType,
@ -44,7 +44,7 @@ where
async fn run_query<F>(query: &str, f: F) async fn run_query<F>(query: &str, f: F)
where where
F: Fn(&Object<DefaultScalarValue>) -> (), F: Fn(&Object<DefaultScalarValue>),
{ {
run_variable_query(query, Variables::new(), f).await; run_variable_query(query, Variables::new(), f).await;
} }

View file

@ -32,7 +32,7 @@ impl TestType {
async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F) async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
where where
F: Fn(&Object<DefaultScalarValue>) -> (), F: Fn(&Object<DefaultScalarValue>),
{ {
let schema = RootNode::new( let schema = RootNode::new(
TestType, TestType,
@ -55,7 +55,7 @@ where
async fn run_query<F>(query: &str, f: F) async fn run_query<F>(query: &str, f: F)
where where
F: Fn(&Object<DefaultScalarValue>) -> (), F: Fn(&Object<DefaultScalarValue>),
{ {
run_variable_query(query, Variables::new(), f).await; run_variable_query(query, Variables::new(), f).await;
} }

View file

@ -89,7 +89,7 @@ impl Root {
async fn run_type_info_query<F>(doc: &str, f: F) async fn run_type_info_query<F>(doc: &str, f: F)
where where
F: Fn((&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>)) -> (), F: Fn((&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>)),
{ {
let schema = RootNode::new( let schema = RootNode::new(
Root, Root,

View file

@ -114,7 +114,7 @@ impl Root {
async fn run_type_info_query<F>(doc: &str, f: F) async fn run_type_info_query<F>(doc: &str, f: F)
where where
F: Fn(&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>) -> (), F: Fn(&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>),
{ {
let schema = RootNode::new( let schema = RootNode::new(
Root, Root,

View file

@ -120,7 +120,7 @@ impl TestType {
async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F) async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
where where
F: Fn(&Object<DefaultScalarValue>) -> (), F: Fn(&Object<DefaultScalarValue>),
{ {
let schema = RootNode::new( let schema = RootNode::new(
TestType, TestType,
@ -143,7 +143,7 @@ where
async fn run_query<F>(query: &str, f: F) async fn run_query<F>(query: &str, f: F)
where where
F: Fn(&Object<DefaultScalarValue>) -> (), F: Fn(&Object<DefaultScalarValue>),
{ {
run_variable_query(query, graphql_vars! {}, f).await; run_variable_query(query, graphql_vars! {}, f).await;
} }

View file

@ -16,7 +16,7 @@ where
s, s,
&SchemaType::new::<QueryRoot, MutationRoot, SubscriptionRoot>(&(), &(), &()), &SchemaType::new::<QueryRoot, MutationRoot, SubscriptionRoot>(&(), &(), &()),
) )
.expect(&format!("Parse error on input {s:#?}")) .unwrap_or_else(|_| panic!("Parse error on input {s:#?}"))
} }
fn parse_document_error<S: ScalarValue>(s: &str) -> Spanning<ParseError> { fn parse_document_error<S: ScalarValue>(s: &str) -> Spanning<ParseError> {

View file

@ -1,6 +1,6 @@
use crate::parser::{Lexer, LexerError, ScalarToken, SourcePosition, Spanning, Token}; use crate::parser::{Lexer, LexerError, ScalarToken, SourcePosition, Spanning, Token};
fn tokenize_to_vec<'a>(s: &'a str) -> Vec<Spanning<Token<'a>>> { fn tokenize_to_vec(s: &str) -> Vec<Spanning<Token<'_>>> {
let mut tokens = Vec::new(); let mut tokens = Vec::new();
let mut lexer = Lexer::new(s); let mut lexer = Lexer::new(s);
@ -21,7 +21,7 @@ fn tokenize_to_vec<'a>(s: &'a str) -> Vec<Spanning<Token<'a>>> {
tokens tokens
} }
fn tokenize_single<'a>(s: &'a str) -> Spanning<Token<'a>> { fn tokenize_single(s: &str) -> Spanning<Token<'_>> {
let mut tokens = tokenize_to_vec(s); let mut tokens = tokenize_to_vec(s);
assert_eq!(tokens.len(), 2); assert_eq!(tokens.len(), 2);
@ -178,7 +178,7 @@ fn strings() {
Spanning::start_end( Spanning::start_end(
&SourcePosition::new(0, 0, 0), &SourcePosition::new(0, 0, 0),
&SourcePosition::new(20, 0, 20), &SourcePosition::new(20, 0, 20),
Token::Scalar(ScalarToken::String(r#"escaped \n\r\b\t\f"#)) Token::Scalar(ScalarToken::String(r"escaped \n\r\b\t\f"))
) )
); );
@ -187,7 +187,7 @@ fn strings() {
Spanning::start_end( Spanning::start_end(
&SourcePosition::new(0, 0, 0), &SourcePosition::new(0, 0, 0),
&SourcePosition::new(15, 0, 15), &SourcePosition::new(15, 0, 15),
Token::Scalar(ScalarToken::String(r#"slashes \\ \/"#)) Token::Scalar(ScalarToken::String(r"slashes \\ \/"))
) )
); );
@ -196,7 +196,7 @@ fn strings() {
Spanning::start_end( Spanning::start_end(
&SourcePosition::new(0, 0, 0), &SourcePosition::new(0, 0, 0),
&SourcePosition::new(34, 0, 34), &SourcePosition::new(34, 0, 34),
Token::Scalar(ScalarToken::String(r#"unicode \u1234\u5678\u90AB\uCDEF"#)), Token::Scalar(ScalarToken::String(r"unicode \u1234\u5678\u90AB\uCDEF")),
) )
); );
} }

View file

@ -36,7 +36,7 @@ impl Query {
} }
fn float_field() -> f64 { fn float_field() -> f64 {
3.14 3.12
} }
fn string_field() -> String { fn string_field() -> String {
@ -65,11 +65,12 @@ where
S: ScalarValue, S: ScalarValue,
{ {
let mut lexer = Lexer::new(s); let mut lexer = Lexer::new(s);
let mut parser = Parser::new(&mut lexer).expect(&format!("Lexer error on input {s:#?}")); let mut parser =
Parser::new(&mut lexer).unwrap_or_else(|_| panic!("Lexer error on input {s:#?}"));
let schema = SchemaType::new::<Query, EmptyMutation<()>, EmptySubscription<()>>(&(), &(), &()); let schema = SchemaType::new::<Query, EmptyMutation<()>, EmptySubscription<()>>(&(), &(), &());
parse_value_literal(&mut parser, false, &schema, Some(meta)) parse_value_literal(&mut parser, false, &schema, Some(meta))
.expect(&format!("Parse error on input {s:#?}")) .unwrap_or_else(|_| panic!("Parse error on input {s:#?}"))
} }
#[test] #[test]

View file

@ -264,7 +264,7 @@ impl GraphQLParserTranslator {
.map(|x| GraphQLParserTranslator::translate_argument(x)) .map(|x| GraphQLParserTranslator::translate_argument(x))
.collect() .collect()
}) })
.unwrap_or_else(Vec::new); .unwrap_or_default();
ExternalField { ExternalField {
position: Pos::default(), position: Pos::default(),

View file

@ -63,7 +63,7 @@ impl MySubscription {
} }
async fn human_with_context(context: &MyContext) -> HumanStream { async fn human_with_context(context: &MyContext) -> HumanStream {
let context_val = context.0.clone(); let context_val = context.0;
Box::pin(stream::once(async move { Box::pin(stream::once(async move {
Human { Human {
id: context_val.to_string(), id: context_val.to_string(),
@ -110,7 +110,7 @@ fn create_and_execute(
let (values, errors) = response.unwrap(); let (values, errors) = response.unwrap();
if errors.len() > 0 { if !errors.is_empty() {
return Err(errors); return Err(errors);
} }
@ -192,7 +192,7 @@ fn returns_error() {
let expected_error = ExecutionError::new( let expected_error = ExecutionError::new(
crate::parser::SourcePosition::new(23, 1, 8), crate::parser::SourcePosition::new(23, 1, 8),
&vec!["errorHuman"], &["errorHuman"],
FieldError::new("handler error", graphql_value!("more details")), FieldError::new("handler error", graphql_value!("more details")),
); );

View file

@ -630,10 +630,7 @@ pub(crate) fn merge_key_into<S>(result: &mut Object<S>, response_name: &str, val
} }
Value::List(dest_list) => { Value::List(dest_list) => {
if let Value::List(src_list) = value { if let Value::List(src_list) = value {
dest_list dest_list.iter_mut().zip(src_list).for_each(|(d, s)| {
.iter_mut()
.zip(src_list.into_iter())
.for_each(|(d, s)| {
if let Value::Object(d_obj) = d { if let Value::Object(d_obj) = d {
if let Value::Object(s_obj) = s { if let Value::Object(s_obj) = s {
merge_maps(d_obj, s_obj); merge_maps(d_obj, s_obj);

View file

@ -511,10 +511,10 @@ mod tests {
parse_string("simple", "simple"); parse_string("simple", "simple");
parse_string(" white space ", " white space "); parse_string(" white space ", " white space ");
parse_string(r#"quote \""#, "quote \""); parse_string(r#"quote \""#, "quote \"");
parse_string(r#"escaped \n\r\b\t\f"#, "escaped \n\r\u{0008}\t\u{000c}"); parse_string(r"escaped \n\r\b\t\f", "escaped \n\r\u{0008}\t\u{000c}");
parse_string(r#"slashes \\ \/"#, "slashes \\ /"); parse_string(r"slashes \\ \/", "slashes \\ /");
parse_string( parse_string(
r#"unicode \u1234\u5678\u90AB\uCDEF"#, r"unicode \u1234\u5678\u90AB\uCDEF",
"unicode \u{1234}\u{5678}\u{90ab}\u{cdef}", "unicode \u{1234}\u{5678}\u{90ab}\u{cdef}",
); );
} }

View file

@ -72,7 +72,7 @@ where
if let Some(current_fragment) = self.current_fragment { if let Some(current_fragment) = self.current_fragment {
self.spreads self.spreads
.entry(current_fragment) .entry(current_fragment)
.or_insert_with(Vec::new) .or_default()
.push(Spanning::start_end( .push(Spanning::start_end(
&spread.start, &spread.start,
&spread.end, &spread.end,

View file

@ -133,7 +133,7 @@ where
if let Some(ref scope) = self.current_scope { if let Some(ref scope) = self.current_scope {
self.spreads self.spreads
.entry(scope.clone()) .entry(scope.clone())
.or_insert_with(Vec::new) .or_default()
.push(spread.item.name.item); .push(spread.item.name.item);
} }
} }
@ -158,7 +158,7 @@ where
if let Some(ref scope) = self.current_scope { if let Some(ref scope) = self.current_scope {
self.used_variables self.used_variables
.entry(scope.clone()) .entry(scope.clone())
.or_insert_with(Vec::new) .or_default()
.append( .append(
&mut value &mut value
.item .item

View file

@ -112,7 +112,7 @@ where
if let Some(ref scope) = self.current_scope { if let Some(ref scope) = self.current_scope {
self.spreads self.spreads
.entry(*scope) .entry(*scope)
.or_insert_with(Vec::new) .or_default()
.push(spread.item.name.item); .push(spread.item.name.item);
} }
} }

View file

@ -131,7 +131,7 @@ where
if let Some(ref scope) = self.current_scope { if let Some(ref scope) = self.current_scope {
self.spreads self.spreads
.entry(scope.clone()) .entry(scope.clone())
.or_insert_with(Vec::new) .or_default()
.push(spread.item.name.item); .push(spread.item.name.item);
} }
} }
@ -156,7 +156,7 @@ where
if let Some(ref scope) = self.current_scope { if let Some(ref scope) = self.current_scope {
self.used_variables self.used_variables
.entry(scope.clone()) .entry(scope.clone())
.or_insert_with(Vec::new) .or_default()
.append(&mut value.item.referenced_variables()); .append(&mut value.item.referenced_variables());
} }
} }

View file

@ -122,15 +122,9 @@ impl<'a> PairSet<'a> {
} }
fn insert(&mut self, a: &'a str, b: &'a str, mutex: bool) { fn insert(&mut self, a: &'a str, b: &'a str, mutex: bool) {
self.data self.data.entry(a).or_default().insert(b, mutex);
.entry(a)
.or_insert_with(HashMap::new)
.insert(b, mutex);
self.data self.data.entry(b).or_default().insert(a, mutex);
.entry(b)
.or_insert_with(HashMap::new)
.insert(a, mutex);
} }
} }

View file

@ -139,7 +139,7 @@ where
if let Some(ref scope) = self.current_scope { if let Some(ref scope) = self.current_scope {
self.spreads self.spreads
.entry(scope.clone()) .entry(scope.clone())
.or_insert_with(HashSet::new) .or_default()
.insert(spread.item.name.item); .insert(spread.item.name.item);
} }
} }
@ -152,7 +152,7 @@ where
if let Some(ref scope) = self.current_scope { if let Some(ref scope) = self.current_scope {
self.variable_defs self.variable_defs
.entry(scope.clone()) .entry(scope.clone())
.or_insert_with(Vec::new) .or_default()
.push(def); .push(def);
} }
} }
@ -167,7 +167,7 @@ where
{ {
self.variable_usages self.variable_usages
.entry(scope.clone()) .entry(scope.clone())
.or_insert_with(Vec::new) .or_default()
.push(( .push((
Spanning::start_end(&var_name.start, &var_name.end, var_name.item), Spanning::start_end(&var_name.start, &var_name.end, var_name.item),
input_type.clone(), input_type.clone(),

View file

@ -922,8 +922,8 @@ where
false, false,
)); ));
let doc = let doc = parse_document_source(q, &root.schema)
parse_document_source(q, &root.schema).expect(&format!("Parse error on input {q:#?}")); .unwrap_or_else(|_| panic!("Parse error on input {q:#?}"));
let mut ctx = ValidatorContext::new(unsafe { mem::transmute(&root.schema) }, &doc); let mut ctx = ValidatorContext::new(unsafe { mem::transmute(&root.schema) }, &doc);
visit_fn(&mut ctx, unsafe { mem::transmute(doc.as_slice()) }); visit_fn(&mut ctx, unsafe { mem::transmute(doc.as_slice()) });

View file

@ -570,7 +570,7 @@ mod tests {
let req = TestRequest::post() let req = TestRequest::post()
.append_header(("content-type", "application/json; charset=utf-8")) .append_header(("content-type", "application/json; charset=utf-8"))
.set_payload( .set_payload(
r##"{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }"##, r#"{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }"#,
) )
.uri("/") .uri("/")
.to_request(); .to_request();
@ -643,10 +643,10 @@ mod tests {
let req = TestRequest::post() let req = TestRequest::post()
.append_header(("content-type", "application/json")) .append_header(("content-type", "application/json"))
.set_payload( .set_payload(
r##"[ r#"[
{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }, { "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" },
{ "variables": null, "query": "{ hero(episode: EMPIRE) { id name } }" } { "variables": null, "query": "{ hero(episode: EMPIRE) { id name } }" }
]"##, ]"#,
) )
.uri("/") .uri("/")
.to_request(); .to_request();
@ -857,6 +857,6 @@ mod subscription_tests {
#[actix_web::rt::test] #[actix_web::rt::test]
async fn test_actix_ws_integration() { async fn test_actix_ws_integration() {
run_ws_test_suite(&mut TestActixWsIntegration::default()).await; run_ws_test_suite(&mut TestActixWsIntegration).await;
} }
} }

View file

@ -79,7 +79,7 @@ mod test {
ClientMessage::ConnectionInit { ClientMessage::ConnectionInit {
payload: graphql_vars! {"foo": "bar"}, payload: graphql_vars! {"foo": "bar"},
}, },
serde_json::from_str(r##"{"type": "connection_init", "payload": {"foo": "bar"}}"##) serde_json::from_str(r#"{"type": "connection_init", "payload": {"foo": "bar"}}"#)
.unwrap(), .unwrap(),
); );
@ -87,7 +87,7 @@ mod test {
ClientMessage::ConnectionInit { ClientMessage::ConnectionInit {
payload: graphql_vars! {}, payload: graphql_vars! {},
}, },
serde_json::from_str(r##"{"type": "connection_init"}"##).unwrap(), serde_json::from_str(r#"{"type": "connection_init"}"#).unwrap(),
); );
assert_eq!( assert_eq!(
@ -101,13 +101,13 @@ mod test {
}, },
}, },
serde_json::from_str( serde_json::from_str(
r##"{"type": "subscribe", "id": "foo", "payload": { r#"{"type": "subscribe", "id": "foo", "payload": {
"query": "query MyQuery { __typename }", "query": "query MyQuery { __typename }",
"variables": { "variables": {
"foo": "bar" "foo": "bar"
}, },
"operationName": "MyQuery" "operationName": "MyQuery"
}}"## }}"#
) )
.unwrap(), .unwrap(),
); );
@ -123,16 +123,16 @@ mod test {
}, },
}, },
serde_json::from_str( serde_json::from_str(
r##"{"type": "subscribe", "id": "foo", "payload": { r#"{"type": "subscribe", "id": "foo", "payload": {
"query": "query MyQuery { __typename }" "query": "query MyQuery { __typename }"
}}"## }}"#
) )
.unwrap(), .unwrap(),
); );
assert_eq!( assert_eq!(
ClientMessage::Complete { id: "foo".into() }, ClientMessage::Complete { id: "foo".into() },
serde_json::from_str(r##"{"type": "complete", "id": "foo"}"##).unwrap(), serde_json::from_str(r#"{"type": "complete", "id": "foo"}"#).unwrap(),
); );
} }

View file

@ -949,7 +949,7 @@ mod test {
Output::Message(ServerMessage::Error { id, .. }) => { Output::Message(ServerMessage::Error { id, .. }) => {
assert_eq!(id, "bar"); assert_eq!(id, "bar");
} }
msg @ _ => panic!("expected error, got: {msg:?}"), msg => panic!("expected error, got: {msg:?}"),
} }
} }
@ -991,10 +991,10 @@ mod test {
item: ParseError::UnexpectedToken(token), item: ParseError::UnexpectedToken(token),
.. ..
}) => assert_eq!(token, "asd"), }) => assert_eq!(token, "asd"),
p @ _ => panic!("expected graphql parse error, got: {p:?}"), p => panic!("expected graphql parse error, got: {p:?}"),
} }
} }
msg @ _ => panic!("expected error, got: {msg:?}"), msg => panic!("expected error, got: {msg:?}"),
} }
} }
@ -1106,7 +1106,7 @@ mod test {
assert_eq!(data, graphql_value!({ "error": null })); assert_eq!(data, graphql_value!({ "error": null }));
assert_eq!(errors.len(), 1); assert_eq!(errors.len(), 1);
} }
msg @ _ => panic!("expected data, got: {msg:?}"), msg => panic!("expected data, got: {msg:?}"),
} }
} }
} }

View file

@ -121,12 +121,12 @@ mod test {
assert_eq!( assert_eq!(
serde_json::to_string(&ServerMessage::ConnectionAck).unwrap(), serde_json::to_string(&ServerMessage::ConnectionAck).unwrap(),
r##"{"type":"connection_ack"}"##, r#"{"type":"connection_ack"}"#,
); );
assert_eq!( assert_eq!(
serde_json::to_string(&ServerMessage::Pong).unwrap(), serde_json::to_string(&ServerMessage::Pong).unwrap(),
r##"{"type":"pong"}"##, r#"{"type":"pong"}"#,
); );
assert_eq!( assert_eq!(
@ -138,7 +138,7 @@ mod test {
}, },
}) })
.unwrap(), .unwrap(),
r##"{"type":"next","id":"foo","payload":{"data":null}}"##, r#"{"type":"next","id":"foo","payload":{"data":null}}"#,
); );
assert_eq!( assert_eq!(
@ -147,12 +147,12 @@ mod test {
payload: GraphQLError::UnknownOperationName.into(), payload: GraphQLError::UnknownOperationName.into(),
}) })
.unwrap(), .unwrap(),
r##"{"type":"error","id":"foo","payload":[{"message":"Unknown operation"}]}"##, r#"{"type":"error","id":"foo","payload":[{"message":"Unknown operation"}]}"#,
); );
assert_eq!( assert_eq!(
serde_json::to_string(&ServerMessage::Complete { id: "foo".into() }).unwrap(), serde_json::to_string(&ServerMessage::Complete { id: "foo".into() }).unwrap(),
r##"{"type":"complete","id":"foo"}"##, r#"{"type":"complete","id":"foo"}"#,
); );
} }
} }

View file

@ -65,7 +65,7 @@ mod test {
ClientMessage::ConnectionInit { ClientMessage::ConnectionInit {
payload: graphql_vars! {"foo": "bar"}, payload: graphql_vars! {"foo": "bar"},
}, },
serde_json::from_str(r##"{"type": "connection_init", "payload": {"foo": "bar"}}"##) serde_json::from_str(r#"{"type": "connection_init", "payload": {"foo": "bar"}}"#)
.unwrap(), .unwrap(),
); );
@ -73,7 +73,7 @@ mod test {
ClientMessage::ConnectionInit { ClientMessage::ConnectionInit {
payload: graphql_vars! {}, payload: graphql_vars! {},
}, },
serde_json::from_str(r##"{"type": "connection_init"}"##).unwrap(), serde_json::from_str(r#"{"type": "connection_init"}"#).unwrap(),
); );
assert_eq!( assert_eq!(
@ -86,13 +86,13 @@ mod test {
}, },
}, },
serde_json::from_str( serde_json::from_str(
r##"{"type": "start", "id": "foo", "payload": { r#"{"type": "start", "id": "foo", "payload": {
"query": "query MyQuery { __typename }", "query": "query MyQuery { __typename }",
"variables": { "variables": {
"foo": "bar" "foo": "bar"
}, },
"operationName": "MyQuery" "operationName": "MyQuery"
}}"## }}"#
) )
.unwrap(), .unwrap(),
); );
@ -107,21 +107,21 @@ mod test {
}, },
}, },
serde_json::from_str( serde_json::from_str(
r##"{"type": "start", "id": "foo", "payload": { r#"{"type": "start", "id": "foo", "payload": {
"query": "query MyQuery { __typename }" "query": "query MyQuery { __typename }"
}}"## }}"#
) )
.unwrap(), .unwrap(),
); );
assert_eq!( assert_eq!(
ClientMessage::Stop { id: "foo".into() }, ClientMessage::Stop { id: "foo".into() },
serde_json::from_str(r##"{"type": "stop", "id": "foo"}"##).unwrap(), serde_json::from_str(r#"{"type": "stop", "id": "foo"}"#).unwrap(),
); );
assert_eq!( assert_eq!(
ClientMessage::ConnectionTerminate, ClientMessage::ConnectionTerminate,
serde_json::from_str(r##"{"type": "connection_terminate"}"##).unwrap(), serde_json::from_str(r#"{"type": "connection_terminate"}"#).unwrap(),
); );
} }

View file

@ -876,7 +876,7 @@ mod test {
ServerMessage::Error { id, .. } => { ServerMessage::Error { id, .. } => {
assert_eq!(id, "bar"); assert_eq!(id, "bar");
} }
msg @ _ => panic!("expected error, got: {msg:?}"), msg => panic!("expected error, got: {msg:?}"),
} }
} }
@ -914,10 +914,10 @@ mod test {
item: ParseError::UnexpectedToken(token), item: ParseError::UnexpectedToken(token),
.. ..
}) => assert_eq!(token, "asd"), }) => assert_eq!(token, "asd"),
p @ _ => panic!("expected graphql parse error, got: {p:?}"), p => panic!("expected graphql parse error, got: {p:?}"),
} }
} }
msg @ _ => panic!("expected error, got: {msg:?}"), msg => panic!("expected error, got: {msg:?}"),
} }
} }
@ -1018,7 +1018,7 @@ mod test {
assert_eq!(data, graphql_value!({ "error": null })); assert_eq!(data, graphql_value!({ "error": null }));
assert_eq!(errors.len(), 1); assert_eq!(errors.len(), 1);
} }
msg @ _ => panic!("expected data, got: {msg:?}"), msg => panic!("expected data, got: {msg:?}"),
} }
} }
} }

View file

@ -144,12 +144,12 @@ mod test {
}, },
}) })
.unwrap(), .unwrap(),
r##"{"type":"connection_error","payload":{"message":"foo"}}"##, r#"{"type":"connection_error","payload":{"message":"foo"}}"#,
); );
assert_eq!( assert_eq!(
serde_json::to_string(&ServerMessage::ConnectionAck).unwrap(), serde_json::to_string(&ServerMessage::ConnectionAck).unwrap(),
r##"{"type":"connection_ack"}"##, r#"{"type":"connection_ack"}"#,
); );
assert_eq!( assert_eq!(
@ -161,7 +161,7 @@ mod test {
}, },
}) })
.unwrap(), .unwrap(),
r##"{"type":"data","id":"foo","payload":{"data":null}}"##, r#"{"type":"data","id":"foo","payload":{"data":null}}"#,
); );
assert_eq!( assert_eq!(
@ -170,17 +170,17 @@ mod test {
payload: GraphQLError::UnknownOperationName.into(), payload: GraphQLError::UnknownOperationName.into(),
}) })
.unwrap(), .unwrap(),
r##"{"type":"error","id":"foo","payload":[{"message":"Unknown operation"}]}"##, r#"{"type":"error","id":"foo","payload":[{"message":"Unknown operation"}]}"#,
); );
assert_eq!( assert_eq!(
serde_json::to_string(&ServerMessage::Complete { id: "foo".into() }).unwrap(), serde_json::to_string(&ServerMessage::Complete { id: "foo".into() }).unwrap(),
r##"{"type":"complete","id":"foo"}"##, r#"{"type":"complete","id":"foo"}"#,
); );
assert_eq!( assert_eq!(
serde_json::to_string(&ServerMessage::ConnectionKeepAlive).unwrap(), serde_json::to_string(&ServerMessage::ConnectionKeepAlive).unwrap(),
r##"{"type":"ka"}"##, r#"{"type":"ka"}"#,
); );
} }
} }

View file

@ -325,7 +325,9 @@ mod tests {
impl http_tests::HttpIntegration for TestHyperIntegration { impl http_tests::HttpIntegration for TestHyperIntegration {
fn get(&self, url: &str) -> http_tests::TestResponse { fn get(&self, url: &str) -> http_tests::TestResponse {
let url = format!("http://127.0.0.1:{}/graphql{url}", self.port); let url = format!("http://127.0.0.1:{}/graphql{url}", self.port);
make_test_response(reqwest::blocking::get(&url).expect(&format!("failed GET {url}"))) make_test_response(
reqwest::blocking::get(&url).unwrap_or_else(|_| panic!("failed GET {url}")),
)
} }
fn post_json(&self, url: &str, body: &str) -> http_tests::TestResponse { fn post_json(&self, url: &str, body: &str) -> http_tests::TestResponse {
@ -336,7 +338,7 @@ mod tests {
.header(reqwest::header::CONTENT_TYPE, "application/json") .header(reqwest::header::CONTENT_TYPE, "application/json")
.body(body.to_owned()) .body(body.to_owned())
.send() .send()
.expect(&format!("failed POST {url}")); .unwrap_or_else(|_| panic!("failed POST {url}"));
make_test_response(res) make_test_response(res)
} }
@ -348,7 +350,7 @@ mod tests {
.header(reqwest::header::CONTENT_TYPE, "application/graphql") .header(reqwest::header::CONTENT_TYPE, "application/graphql")
.body(body.to_owned()) .body(body.to_owned())
.send() .send()
.expect(&format!("failed POST {url}")); .unwrap_or_else(|_| panic!("failed POST {url}"));
make_test_response(res) make_test_response(res)
} }
} }

View file

@ -17,7 +17,7 @@ fn get_graphql_handler(
request: juniper_rocket::GraphQLRequest, request: juniper_rocket::GraphQLRequest,
schema: &State<Schema>, schema: &State<Schema>,
) -> juniper_rocket::GraphQLResponse { ) -> juniper_rocket::GraphQLResponse {
request.execute_sync(&*schema, &*context) request.execute_sync(schema, context)
} }
#[rocket::post("/graphql", data = "<request>")] #[rocket::post("/graphql", data = "<request>")]
@ -26,7 +26,7 @@ fn post_graphql_handler(
request: juniper_rocket::GraphQLRequest, request: juniper_rocket::GraphQLRequest,
schema: &State<Schema>, schema: &State<Schema>,
) -> juniper_rocket::GraphQLResponse { ) -> juniper_rocket::GraphQLResponse {
request.execute_sync(&*schema, &*context) request.execute_sync(schema, context)
} }
#[rocket::main] #[rocket::main]

View file

@ -490,8 +490,6 @@ mod fromform_tests {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use futures;
use juniper::{ use juniper::{
http::tests as http_tests, http::tests as http_tests,
tests::fixtures::starwars::schema::{Database, Query}, tests::fixtures::starwars::schema::{Database, Query},
@ -512,7 +510,7 @@ mod tests {
request: super::GraphQLRequest, request: super::GraphQLRequest,
schema: &State<Schema>, schema: &State<Schema>,
) -> super::GraphQLResponse { ) -> super::GraphQLResponse {
request.execute_sync(&*schema, &*context) request.execute_sync(schema, context)
} }
#[post("/", data = "<request>")] #[post("/", data = "<request>")]
@ -521,7 +519,7 @@ mod tests {
request: super::GraphQLRequest, request: super::GraphQLRequest,
schema: &State<Schema>, schema: &State<Schema>,
) -> super::GraphQLResponse { ) -> super::GraphQLResponse {
request.execute_sync(&*schema, &*context) request.execute_sync(schema, context)
} }
struct TestRocketIntegration { struct TestRocketIntegration {
@ -570,7 +568,7 @@ mod tests {
schema: &State<Schema>, schema: &State<Schema>,
) -> super::GraphQLResponse { ) -> super::GraphQLResponse {
assert_eq!(request.operation_names(), vec![Some("TestQuery")]); assert_eq!(request.operation_names(), vec![Some("TestQuery")]);
request.execute_sync(&*schema, &*context) request.execute_sync(schema, context)
} }
let rocket = make_rocket_without_routes() let rocket = make_rocket_without_routes()

View file

@ -35,7 +35,7 @@ async fn main() {
log::info!("Listening on 127.0.0.1:8080"); log::info!("Listening on 127.0.0.1:8080");
let state = warp::any().map(move || Database::new()); let state = warp::any().map(Database::new);
let graphql_filter = juniper_warp::make_graphql_filter(schema(), state.boxed()); let graphql_filter = juniper_warp::make_graphql_filter(schema(), state.boxed());
warp::serve( warp::serve(

View file

@ -641,7 +641,7 @@ mod tests {
.path("/graphql2") .path("/graphql2")
.header("accept", "application/json") .header("accept", "application/json")
.header("content-type", "application/json") .header("content-type", "application/json")
.body(r##"{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }"##) .body(r#"{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }"#)
.reply(&filter) .reply(&filter)
.await; .await;
@ -681,10 +681,10 @@ mod tests {
.header("accept", "application/json") .header("accept", "application/json")
.header("content-type", "application/json") .header("content-type", "application/json")
.body( .body(
r##"[ r#"[
{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }, { "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" },
{ "variables": null, "query": "{ hero(episode: EMPIRE) { id name } }" } { "variables": null, "query": "{ hero(episode: EMPIRE) { id name } }" }
]"##, ]"#,
) )
.reply(&filter) .reply(&filter)
.await; .await;
@ -734,7 +734,7 @@ mod tests_http_harness {
EmptyMutation::<Database>::new(), EmptyMutation::<Database>::new(),
EmptySubscription::<Database>::new(), EmptySubscription::<Database>::new(),
); );
let state = warp::any().map(move || Database::new()); let state = warp::any().map(Database::new);
let filter = path::end().and(if is_sync { let filter = path::end().and(if is_sync {
make_graphql_filter_sync(schema, state.boxed()) make_graphql_filter_sync(schema, state.boxed())
@ -779,7 +779,6 @@ mod tests_http_harness {
let url = Url::parse(&format!("http://localhost:3000{url}")).expect("url to parse"); let url = Url::parse(&format!("http://localhost:3000{url}")).expect("url to parse");
let url: String = utf8_percent_encode(url.query().unwrap_or(""), QUERY_ENCODE_SET) let url: String = utf8_percent_encode(url.query().unwrap_or(""), QUERY_ENCODE_SET)
.into_iter()
.collect::<Vec<_>>() .collect::<Vec<_>>()
.join(""); .join("");

View file

@ -33,7 +33,7 @@ async fn supports_raw_idents_in_types_and_args() {
} }
"#; "#;
let value = run_type_info_query(&doc).await; let value = run_type_info_query(doc).await;
assert_eq!( assert_eq!(
value, value,
@ -68,7 +68,7 @@ async fn supports_raw_idents_in_fields_of_input_types() {
} }
"#; "#;
let value = run_type_info_query(&doc).await; let value = run_type_info_query(doc).await;
assert_eq!( assert_eq!(
value, value,

View file

@ -2419,10 +2419,11 @@ mod nullable_argument_subtyping {
#[graphql_object(impl = CharacterValue)] #[graphql_object(impl = CharacterValue)]
impl Droid { impl Droid {
fn id(&self, is_present: Option<bool>) -> &str { fn id(&self, is_present: Option<bool>) -> &str {
is_present if is_present.unwrap_or_default() {
.unwrap_or_default() &self.id
.then_some(&*self.id) } else {
.unwrap_or("missing") "missing"
}
} }
fn primary_function(&self) -> &str { fn primary_function(&self) -> &str {

View file

@ -2527,7 +2527,7 @@ mod inferred_custom_context_from_field {
&self.primary_function &self.primary_function
} }
fn info<'b>(&'b self) -> &'b str { fn info(&self) -> &str {
&self.primary_function &self.primary_function
} }
} }
@ -3246,10 +3246,11 @@ mod nullable_argument_subtyping {
#[graphql_object(impl = CharacterValue)] #[graphql_object(impl = CharacterValue)]
impl Droid { impl Droid {
fn id(&self, is_present: Option<bool>) -> &str { fn id(&self, is_present: Option<bool>) -> &str {
is_present if is_present.unwrap_or_default() {
.unwrap_or_default() &self.id
.then_some(&*self.id) } else {
.unwrap_or("missing") "missing"
}
} }
fn primary_function(&self) -> &str { fn primary_function(&self) -> &str {

View file

@ -2439,10 +2439,11 @@ mod nullable_argument_subtyping {
#[graphql_object(impl = CharacterValue)] #[graphql_object(impl = CharacterValue)]
impl Droid { impl Droid {
fn id(&self, is_present: Option<bool>) -> &str { fn id(&self, is_present: Option<bool>) -> &str {
is_present if is_present.unwrap_or_default() {
.unwrap_or_default() &self.id
.then_some(&*self.id) } else {
.unwrap_or("missing") "missing"
}
} }
fn primary_function(&self) -> &str { fn primary_function(&self) -> &str {

View file

@ -299,7 +299,7 @@ mod multiple_delegated_parse_token {
fn from_input<S: ScalarValue>(v: &InputValue<S>) -> Result<StringOrInt, String> { fn from_input<S: ScalarValue>(v: &InputValue<S>) -> Result<StringOrInt, String> {
v.as_string_value() v.as_string_value()
.map(|s| StringOrInt::String(s.to_owned())) .map(|s| StringOrInt::String(s.to_owned()))
.or_else(|| v.as_int_value().map(|i| StringOrInt::Int(i))) .or_else(|| v.as_int_value().map(StringOrInt::Int))
.ok_or_else(|| format!("Expected `String` or `Int`, found: {v}")) .ok_or_else(|| format!("Expected `String` or `Int`, found: {v}"))
} }

View file

@ -74,7 +74,7 @@ mod trivial {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -90,7 +90,7 @@ mod trivial {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"homePlanet": "earth"}), vec![])), Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
); );
@ -171,7 +171,7 @@ mod raw_method {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"myId": "human-32"}), vec![])), Ok((graphql_value!({"myId": "human-32"}), vec![])),
); );
@ -187,7 +187,7 @@ mod raw_method {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"async": "async-32"}), vec![])), Ok((graphql_value!({"async": "async-32"}), vec![])),
); );
@ -249,7 +249,7 @@ mod ignored_method {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -311,7 +311,7 @@ mod fallible_method {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -327,7 +327,7 @@ mod fallible_method {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"homePlanet": "earth"}), vec![])), Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
); );
@ -403,7 +403,7 @@ mod argument {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -419,7 +419,7 @@ mod argument {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"homePlanet": "earth,None"}), vec![])), Ok((graphql_value!({"homePlanet": "earth,None"}), vec![])),
); );
@ -547,7 +547,7 @@ mod default_argument {
] { ] {
assert_eq!( assert_eq!(
resolve_into_stream(input, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(input, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({ "id": expected }), vec![])), Ok((graphql_value!({ "id": expected }), vec![])),
); );
@ -564,7 +564,7 @@ mod default_argument {
] { ] {
assert_eq!( assert_eq!(
resolve_into_stream(input, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(input, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({ "info": expected }), vec![])), Ok((graphql_value!({ "info": expected }), vec![])),
); );
@ -660,7 +660,7 @@ mod generic {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": 34}), vec![])), Ok((graphql_value!({"id": 34}), vec![])),
); );
@ -682,7 +682,7 @@ mod generic {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -760,7 +760,7 @@ mod generic_lifetime {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": 34}), vec![])), Ok((graphql_value!({"id": 34}), vec![])),
); );
@ -782,7 +782,7 @@ mod generic_lifetime {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"planet": "earth"}), vec![])), Ok((graphql_value!({"planet": "earth"}), vec![])),
); );
@ -804,7 +804,7 @@ mod generic_lifetime {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -826,7 +826,7 @@ mod generic_lifetime {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"planet": "mars"}), vec![])), Ok((graphql_value!({"planet": "mars"}), vec![])),
); );
@ -928,7 +928,7 @@ mod deprecation_from_attr {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -944,7 +944,7 @@ mod deprecation_from_attr {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"a": "a"}), vec![])), Ok((graphql_value!({"a": "a"}), vec![])),
); );
@ -960,7 +960,7 @@ mod deprecation_from_attr {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"b": "b"}), vec![])), Ok((graphql_value!({"b": "b"}), vec![])),
); );
@ -1057,7 +1057,7 @@ mod explicit_name_description_and_deprecation {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"myId": "human-32"}), vec![])), Ok((graphql_value!({"myId": "human-32"}), vec![])),
); );
@ -1073,7 +1073,7 @@ mod explicit_name_description_and_deprecation {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"a": "a"}), vec![])), Ok((graphql_value!({"a": "a"}), vec![])),
); );
@ -1089,7 +1089,7 @@ mod explicit_name_description_and_deprecation {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"b": "b"}), vec![])), Ok((graphql_value!({"b": "b"}), vec![])),
); );
@ -1236,7 +1236,7 @@ mod renamed_all_fields_and_args {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -1252,7 +1252,7 @@ mod renamed_all_fields_and_args {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"home_planet": "earth"}), vec![])), Ok((graphql_value!({"home_planet": "earth"}), vec![])),
); );
@ -1268,7 +1268,7 @@ mod renamed_all_fields_and_args {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"async_info": 3}), vec![])), Ok((graphql_value!({"async_info": 3}), vec![])),
); );
@ -1329,7 +1329,7 @@ mod explicit_scalar {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -1345,7 +1345,7 @@ mod explicit_scalar {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"homePlanet": "earth"}), vec![])), Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
); );
@ -1380,7 +1380,7 @@ mod custom_scalar {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -1396,7 +1396,7 @@ mod custom_scalar {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"homePlanet": "earth"}), vec![])), Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
); );
@ -1431,7 +1431,7 @@ mod explicit_generic_scalar {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -1447,7 +1447,7 @@ mod explicit_generic_scalar {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"homePlanet": "earth"}), vec![])), Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
); );
@ -1482,7 +1482,7 @@ mod bounded_generic_scalar {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "human-32"}), vec![])), Ok((graphql_value!({"id": "human-32"}), vec![])),
); );
@ -1498,7 +1498,7 @@ mod bounded_generic_scalar {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"homePlanet": "earth"}), vec![])), Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
); );
@ -1551,7 +1551,7 @@ mod explicit_custom_context {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "ctx!"}), vec![])), Ok((graphql_value!({"id": "ctx!"}), vec![])),
); );
@ -1568,7 +1568,7 @@ mod explicit_custom_context {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"info": "human being"}), vec![])), Ok((graphql_value!({"info": "human being"}), vec![])),
); );
@ -1585,7 +1585,7 @@ mod explicit_custom_context {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"more": "ctx!"}), vec![])), Ok((graphql_value!({"more": "ctx!"}), vec![])),
); );
@ -1638,7 +1638,7 @@ mod inferred_custom_context_from_field {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "ctx!"}), vec![])), Ok((graphql_value!({"id": "ctx!"}), vec![])),
); );
@ -1655,7 +1655,7 @@ mod inferred_custom_context_from_field {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"info": "human being"}), vec![])), Ok((graphql_value!({"info": "human being"}), vec![])),
); );
@ -1672,7 +1672,7 @@ mod inferred_custom_context_from_field {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"more": "ctx!"}), vec![])), Ok((graphql_value!({"more": "ctx!"}), vec![])),
); );
@ -1724,7 +1724,7 @@ mod executor {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"id": "id"}), vec![])), Ok((graphql_value!({"id": "id"}), vec![])),
); );
@ -1740,7 +1740,7 @@ mod executor {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"info": "input!"}), vec![])), Ok((graphql_value!({"info": "input!"}), vec![])),
); );
@ -1756,7 +1756,7 @@ mod executor {
assert_eq!( assert_eq!(
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &()) resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
.then(|s| extract_next(s)) .then(extract_next)
.await, .await,
Ok((graphql_value!({"info2": "no info"}), vec![])), Ok((graphql_value!({"info2": "no info"}), vec![])),
); );

View file

@ -70,13 +70,13 @@ mod trivial {
impl Character for Human { impl Character for Human {
fn as_human(&self) -> Option<&Human> { fn as_human(&self) -> Option<&Human> {
Some(&self) Some(self)
} }
} }
impl Character for Droid { impl Character for Droid {
fn as_droid(&self) -> Option<&Droid> { fn as_droid(&self) -> Option<&Droid> {
Some(&self) Some(self)
} }
} }
@ -207,13 +207,13 @@ mod generic {
impl<A, B> Character<A, B> for Human { impl<A, B> Character<A, B> for Human {
fn as_human(&self) -> Option<&Human> { fn as_human(&self) -> Option<&Human> {
Some(&self) Some(self)
} }
} }
impl<A, B> Character<A, B> for Droid { impl<A, B> Character<A, B> for Droid {
fn as_droid(&self) -> Option<&Droid> { fn as_droid(&self) -> Option<&Droid> {
Some(&self) Some(self)
} }
} }
@ -310,7 +310,7 @@ mod description_from_doc_comment {
impl Character for Human { impl Character for Human {
fn as_human(&self) -> Option<&Human> { fn as_human(&self) -> Option<&Human> {
Some(&self) Some(self)
} }
} }
@ -383,7 +383,7 @@ mod explicit_name_and_description {
impl Character for Human { impl Character for Human {
fn as_human(&self) -> Option<&Human> { fn as_human(&self) -> Option<&Human> {
Some(&self) Some(self)
} }
} }
@ -474,13 +474,13 @@ mod explicit_scalar {
impl Character for Human { impl Character for Human {
fn as_human(&self) -> Option<&Human> { fn as_human(&self) -> Option<&Human> {
Some(&self) Some(self)
} }
} }
impl Character for Droid { impl Character for Droid {
fn as_droid(&self) -> Option<&Droid> { fn as_droid(&self) -> Option<&Droid> {
Some(&self) Some(self)
} }
} }
@ -565,13 +565,13 @@ mod custom_scalar {
impl Character for Human { impl Character for Human {
fn as_human(&self) -> Option<&Human> { fn as_human(&self) -> Option<&Human> {
Some(&self) Some(self)
} }
} }
impl Character for Droid { impl Character for Droid {
fn as_droid(&self) -> Option<&Droid> { fn as_droid(&self) -> Option<&Droid> {
Some(&self) Some(self)
} }
} }
@ -654,13 +654,13 @@ mod explicit_generic_scalar {
impl<S: ScalarValue> Character<S> for Human { impl<S: ScalarValue> Character<S> for Human {
fn as_human(&self) -> Option<&Human> { fn as_human(&self) -> Option<&Human> {
Some(&self) Some(self)
} }
} }
impl<S: ScalarValue> Character<S> for Droid { impl<S: ScalarValue> Character<S> for Droid {
fn as_droid(&self) -> Option<&Droid> { fn as_droid(&self) -> Option<&Droid> {
Some(&self) Some(self)
} }
} }
@ -743,13 +743,13 @@ mod bounded_generic_scalar {
impl Character for Human { impl Character for Human {
fn as_human(&self) -> Option<&Human> { fn as_human(&self) -> Option<&Human> {
Some(&self) Some(self)
} }
} }
impl Character for Droid { impl Character for Droid {
fn as_droid(&self) -> Option<&Droid> { fn as_droid(&self) -> Option<&Droid> {
Some(&self) Some(self)
} }
} }
@ -832,13 +832,13 @@ mod explicit_custom_context {
impl Character for HumanCustomContext { impl Character for HumanCustomContext {
fn as_human(&self) -> Option<&HumanCustomContext> { fn as_human(&self) -> Option<&HumanCustomContext> {
Some(&self) Some(self)
} }
} }
impl Character for DroidCustomContext { impl Character for DroidCustomContext {
fn as_droid(&self) -> Option<&DroidCustomContext> { fn as_droid(&self) -> Option<&DroidCustomContext> {
Some(&self) Some(self)
} }
} }
@ -919,13 +919,13 @@ mod inferred_custom_context {
impl Character for HumanCustomContext { impl Character for HumanCustomContext {
fn as_human(&self, _: &CustomContext) -> Option<&HumanCustomContext> { fn as_human(&self, _: &CustomContext) -> Option<&HumanCustomContext> {
Some(&self) Some(self)
} }
} }
impl Character for DroidCustomContext { impl Character for DroidCustomContext {
fn as_droid(&self, _: &()) -> Option<&DroidCustomContext> { fn as_droid(&self, _: &()) -> Option<&DroidCustomContext> {
Some(&self) Some(self)
} }
} }
@ -1009,7 +1009,7 @@ mod ignored_method {
impl Character for Human { impl Character for Human {
fn as_human(&self) -> Option<&Human> { fn as_human(&self) -> Option<&Human> {
Some(&self) Some(self)
} }
} }
@ -1084,7 +1084,7 @@ mod external_resolver {
impl Character for Human { impl Character for Human {
fn as_human(&self) -> Option<&Human> { fn as_human(&self) -> Option<&Human> {
Some(&self) Some(self)
} }
} }
@ -1197,19 +1197,19 @@ mod full_featured {
impl<T> Character<T> for HumanCustomContext { impl<T> Character<T> for HumanCustomContext {
fn as_human(&self, _: &()) -> Option<&HumanCustomContext> { fn as_human(&self, _: &()) -> Option<&HumanCustomContext> {
Some(&self) Some(self)
} }
} }
impl<T> Character<T> for DroidCustomContext { impl<T> Character<T> for DroidCustomContext {
fn as_droid(&self) -> Option<&DroidCustomContext> { fn as_droid(&self) -> Option<&DroidCustomContext> {
Some(&self) Some(self)
} }
} }
impl<T> Character<T> for EwokCustomContext { impl<T> Character<T> for EwokCustomContext {
fn as_ewok(&self) -> Option<&EwokCustomContext> { fn as_ewok(&self) -> Option<&EwokCustomContext> {
Some(&self) Some(self)
} }
} }

View file

@ -63,7 +63,7 @@ impl TestSubscriptionType {
async fn run_variable_query<F>(query: &str, vars: Variables<MyScalarValue>, f: F) async fn run_variable_query<F>(query: &str, vars: Variables<MyScalarValue>, f: F)
where where
F: Fn(&Object<MyScalarValue>) -> (), F: Fn(&Object<MyScalarValue>),
{ {
let schema = let schema =
RootNode::new_with_scalar_value(TestType, EmptyMutation::<()>::new(), TestSubscriptionType); RootNode::new_with_scalar_value(TestType, EmptyMutation::<()>::new(), TestSubscriptionType);
@ -83,7 +83,7 @@ where
async fn run_query<F>(query: &str, f: F) async fn run_query<F>(query: &str, f: F)
where where
F: Fn(&Object<MyScalarValue>) -> (), F: Fn(&Object<MyScalarValue>),
{ {
run_variable_query(query, graphql_vars! {}, f).await; run_variable_query(query, graphql_vars! {}, f).await;
} }

View file

@ -54,7 +54,7 @@ async fn explicit_null() {
}; };
assert_eq!( assert_eq!(
juniper::execute(query, None, &schema, &vars, &Context).await, juniper::execute(query, None, schema, &vars, &Context).await,
Ok(( Ok((
graphql_value!({ graphql_value!({
"literalOneIsExplicitNull": false, "literalOneIsExplicitNull": false,

View file

@ -29,7 +29,7 @@ struct SubscriptionsRoot;
#[graphql_subscription(name = "Subscription")] #[graphql_subscription(name = "Subscription")]
impl SubscriptionsRoot { impl SubscriptionsRoot {
async fn users() -> Result<BoxStream<'static, User>, Error> { async fn users() -> Result<BoxStream<'static, User>, Error> {
Ok(users_stream()?) users_stream()
} }
} }

View file

@ -70,7 +70,7 @@ async fn query_document_can_be_pre_parsed() {
.await .await
.unwrap(); .unwrap();
assert!(errors.len() == 0); assert!(errors.is_empty());
} }
#[tokio::test] #[tokio::test]
@ -85,8 +85,8 @@ async fn subscription_document_can_be_pre_parsed() {
let mut stream = resolve_validated_subscription( let mut stream = resolve_validated_subscription(
&document, &document,
&operation, operation,
&root_node, root_node,
&graphql_vars! {}, &graphql_vars! {},
&Context, &Context,
) )