Clippy fixes (#1181)
This commit is contained in:
parent
27430bf60c
commit
108ccf2715
43 changed files with 190 additions and 200 deletions
|
@ -112,11 +112,7 @@ where
|
|||
Self: PartialEq,
|
||||
{
|
||||
fn partial_cmp(&self, other: &ExecutionError<S>) -> Option<Ordering> {
|
||||
(&self.location, &self.path, &self.error.message).partial_cmp(&(
|
||||
&other.location,
|
||||
&other.path,
|
||||
&other.error.message,
|
||||
))
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ impl TestType {
|
|||
|
||||
async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
|
||||
where
|
||||
F: Fn(&Object<DefaultScalarValue>) -> (),
|
||||
F: Fn(&Object<DefaultScalarValue>),
|
||||
{
|
||||
let schema = RootNode::new(
|
||||
TestType,
|
||||
|
@ -44,7 +44,7 @@ where
|
|||
|
||||
async fn run_query<F>(query: &str, f: F)
|
||||
where
|
||||
F: Fn(&Object<DefaultScalarValue>) -> (),
|
||||
F: Fn(&Object<DefaultScalarValue>),
|
||||
{
|
||||
run_variable_query(query, Variables::new(), f).await;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ impl TestType {
|
|||
|
||||
async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
|
||||
where
|
||||
F: Fn(&Object<DefaultScalarValue>) -> (),
|
||||
F: Fn(&Object<DefaultScalarValue>),
|
||||
{
|
||||
let schema = RootNode::new(
|
||||
TestType,
|
||||
|
@ -55,7 +55,7 @@ where
|
|||
|
||||
async fn run_query<F>(query: &str, f: F)
|
||||
where
|
||||
F: Fn(&Object<DefaultScalarValue>) -> (),
|
||||
F: Fn(&Object<DefaultScalarValue>),
|
||||
{
|
||||
run_variable_query(query, Variables::new(), f).await;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ impl Root {
|
|||
|
||||
async fn run_type_info_query<F>(doc: &str, f: F)
|
||||
where
|
||||
F: Fn((&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>)) -> (),
|
||||
F: Fn((&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>)),
|
||||
{
|
||||
let schema = RootNode::new(
|
||||
Root,
|
||||
|
|
|
@ -114,7 +114,7 @@ impl Root {
|
|||
|
||||
async fn run_type_info_query<F>(doc: &str, f: F)
|
||||
where
|
||||
F: Fn(&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>) -> (),
|
||||
F: Fn(&Object<DefaultScalarValue>, &Vec<Value<DefaultScalarValue>>),
|
||||
{
|
||||
let schema = RootNode::new(
|
||||
Root,
|
||||
|
|
|
@ -120,7 +120,7 @@ impl TestType {
|
|||
|
||||
async fn run_variable_query<F>(query: &str, vars: Variables<DefaultScalarValue>, f: F)
|
||||
where
|
||||
F: Fn(&Object<DefaultScalarValue>) -> (),
|
||||
F: Fn(&Object<DefaultScalarValue>),
|
||||
{
|
||||
let schema = RootNode::new(
|
||||
TestType,
|
||||
|
@ -143,7 +143,7 @@ where
|
|||
|
||||
async fn run_query<F>(query: &str, f: F)
|
||||
where
|
||||
F: Fn(&Object<DefaultScalarValue>) -> (),
|
||||
F: Fn(&Object<DefaultScalarValue>),
|
||||
{
|
||||
run_variable_query(query, graphql_vars! {}, f).await;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ where
|
|||
s,
|
||||
&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> {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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 lexer = Lexer::new(s);
|
||||
|
||||
|
@ -21,7 +21,7 @@ fn tokenize_to_vec<'a>(s: &'a str) -> Vec<Spanning<Token<'a>>> {
|
|||
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);
|
||||
|
||||
assert_eq!(tokens.len(), 2);
|
||||
|
@ -178,7 +178,7 @@ fn strings() {
|
|||
Spanning::start_end(
|
||||
&SourcePosition::new(0, 0, 0),
|
||||
&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(
|
||||
&SourcePosition::new(0, 0, 0),
|
||||
&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(
|
||||
&SourcePosition::new(0, 0, 0),
|
||||
&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")),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ impl Query {
|
|||
}
|
||||
|
||||
fn float_field() -> f64 {
|
||||
3.14
|
||||
3.12
|
||||
}
|
||||
|
||||
fn string_field() -> String {
|
||||
|
@ -65,11 +65,12 @@ where
|
|||
S: ScalarValue,
|
||||
{
|
||||
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<()>>(&(), &(), &());
|
||||
|
||||
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]
|
||||
|
|
|
@ -264,7 +264,7 @@ impl GraphQLParserTranslator {
|
|||
.map(|x| GraphQLParserTranslator::translate_argument(x))
|
||||
.collect()
|
||||
})
|
||||
.unwrap_or_else(Vec::new);
|
||||
.unwrap_or_default();
|
||||
|
||||
ExternalField {
|
||||
position: Pos::default(),
|
||||
|
|
|
@ -63,7 +63,7 @@ impl MySubscription {
|
|||
}
|
||||
|
||||
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 {
|
||||
Human {
|
||||
id: context_val.to_string(),
|
||||
|
@ -110,7 +110,7 @@ fn create_and_execute(
|
|||
|
||||
let (values, errors) = response.unwrap();
|
||||
|
||||
if errors.len() > 0 {
|
||||
if !errors.is_empty() {
|
||||
return Err(errors);
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,7 @@ fn returns_error() {
|
|||
|
||||
let expected_error = ExecutionError::new(
|
||||
crate::parser::SourcePosition::new(23, 1, 8),
|
||||
&vec!["errorHuman"],
|
||||
&["errorHuman"],
|
||||
FieldError::new("handler error", graphql_value!("more details")),
|
||||
);
|
||||
|
||||
|
|
|
@ -630,16 +630,13 @@ pub(crate) fn merge_key_into<S>(result: &mut Object<S>, response_name: &str, val
|
|||
}
|
||||
Value::List(dest_list) => {
|
||||
if let Value::List(src_list) = value {
|
||||
dest_list
|
||||
.iter_mut()
|
||||
.zip(src_list.into_iter())
|
||||
.for_each(|(d, s)| {
|
||||
if let Value::Object(d_obj) = d {
|
||||
if let Value::Object(s_obj) = s {
|
||||
merge_maps(d_obj, s_obj);
|
||||
}
|
||||
dest_list.iter_mut().zip(src_list).for_each(|(d, s)| {
|
||||
if let Value::Object(d_obj) = d {
|
||||
if let Value::Object(s_obj) = s {
|
||||
merge_maps(d_obj, s_obj);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
|
@ -511,10 +511,10 @@ mod tests {
|
|||
parse_string("simple", "simple");
|
||||
parse_string(" white space ", " white space ");
|
||||
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#"slashes \\ \/"#, "slashes \\ /");
|
||||
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#"unicode \u1234\u5678\u90AB\uCDEF"#,
|
||||
r"unicode \u1234\u5678\u90AB\uCDEF",
|
||||
"unicode \u{1234}\u{5678}\u{90ab}\u{cdef}",
|
||||
);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ where
|
|||
if let Some(current_fragment) = self.current_fragment {
|
||||
self.spreads
|
||||
.entry(current_fragment)
|
||||
.or_insert_with(Vec::new)
|
||||
.or_default()
|
||||
.push(Spanning::start_end(
|
||||
&spread.start,
|
||||
&spread.end,
|
||||
|
|
|
@ -133,7 +133,7 @@ where
|
|||
if let Some(ref scope) = self.current_scope {
|
||||
self.spreads
|
||||
.entry(scope.clone())
|
||||
.or_insert_with(Vec::new)
|
||||
.or_default()
|
||||
.push(spread.item.name.item);
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ where
|
|||
if let Some(ref scope) = self.current_scope {
|
||||
self.used_variables
|
||||
.entry(scope.clone())
|
||||
.or_insert_with(Vec::new)
|
||||
.or_default()
|
||||
.append(
|
||||
&mut value
|
||||
.item
|
||||
|
|
|
@ -112,7 +112,7 @@ where
|
|||
if let Some(ref scope) = self.current_scope {
|
||||
self.spreads
|
||||
.entry(*scope)
|
||||
.or_insert_with(Vec::new)
|
||||
.or_default()
|
||||
.push(spread.item.name.item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ where
|
|||
if let Some(ref scope) = self.current_scope {
|
||||
self.spreads
|
||||
.entry(scope.clone())
|
||||
.or_insert_with(Vec::new)
|
||||
.or_default()
|
||||
.push(spread.item.name.item);
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ where
|
|||
if let Some(ref scope) = self.current_scope {
|
||||
self.used_variables
|
||||
.entry(scope.clone())
|
||||
.or_insert_with(Vec::new)
|
||||
.or_default()
|
||||
.append(&mut value.item.referenced_variables());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,15 +122,9 @@ impl<'a> PairSet<'a> {
|
|||
}
|
||||
|
||||
fn insert(&mut self, a: &'a str, b: &'a str, mutex: bool) {
|
||||
self.data
|
||||
.entry(a)
|
||||
.or_insert_with(HashMap::new)
|
||||
.insert(b, mutex);
|
||||
self.data.entry(a).or_default().insert(b, mutex);
|
||||
|
||||
self.data
|
||||
.entry(b)
|
||||
.or_insert_with(HashMap::new)
|
||||
.insert(a, mutex);
|
||||
self.data.entry(b).or_default().insert(a, mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ where
|
|||
if let Some(ref scope) = self.current_scope {
|
||||
self.spreads
|
||||
.entry(scope.clone())
|
||||
.or_insert_with(HashSet::new)
|
||||
.or_default()
|
||||
.insert(spread.item.name.item);
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ where
|
|||
if let Some(ref scope) = self.current_scope {
|
||||
self.variable_defs
|
||||
.entry(scope.clone())
|
||||
.or_insert_with(Vec::new)
|
||||
.or_default()
|
||||
.push(def);
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ where
|
|||
{
|
||||
self.variable_usages
|
||||
.entry(scope.clone())
|
||||
.or_insert_with(Vec::new)
|
||||
.or_default()
|
||||
.push((
|
||||
Spanning::start_end(&var_name.start, &var_name.end, var_name.item),
|
||||
input_type.clone(),
|
||||
|
|
|
@ -922,8 +922,8 @@ where
|
|||
false,
|
||||
));
|
||||
|
||||
let doc =
|
||||
parse_document_source(q, &root.schema).expect(&format!("Parse error on input {q:#?}"));
|
||||
let doc = parse_document_source(q, &root.schema)
|
||||
.unwrap_or_else(|_| panic!("Parse error on input {q:#?}"));
|
||||
let mut ctx = ValidatorContext::new(unsafe { mem::transmute(&root.schema) }, &doc);
|
||||
|
||||
visit_fn(&mut ctx, unsafe { mem::transmute(doc.as_slice()) });
|
||||
|
|
|
@ -570,7 +570,7 @@ mod tests {
|
|||
let req = TestRequest::post()
|
||||
.append_header(("content-type", "application/json; charset=utf-8"))
|
||||
.set_payload(
|
||||
r##"{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }"##,
|
||||
r#"{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" }"#,
|
||||
)
|
||||
.uri("/")
|
||||
.to_request();
|
||||
|
@ -643,10 +643,10 @@ mod tests {
|
|||
let req = TestRequest::post()
|
||||
.append_header(("content-type", "application/json"))
|
||||
.set_payload(
|
||||
r##"[
|
||||
r#"[
|
||||
{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" },
|
||||
{ "variables": null, "query": "{ hero(episode: EMPIRE) { id name } }" }
|
||||
]"##,
|
||||
]"#,
|
||||
)
|
||||
.uri("/")
|
||||
.to_request();
|
||||
|
@ -857,6 +857,6 @@ mod subscription_tests {
|
|||
|
||||
#[actix_web::rt::test]
|
||||
async fn test_actix_ws_integration() {
|
||||
run_ws_test_suite(&mut TestActixWsIntegration::default()).await;
|
||||
run_ws_test_suite(&mut TestActixWsIntegration).await;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ mod test {
|
|||
ClientMessage::ConnectionInit {
|
||||
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(),
|
||||
);
|
||||
|
||||
|
@ -87,7 +87,7 @@ mod test {
|
|||
ClientMessage::ConnectionInit {
|
||||
payload: graphql_vars! {},
|
||||
},
|
||||
serde_json::from_str(r##"{"type": "connection_init"}"##).unwrap(),
|
||||
serde_json::from_str(r#"{"type": "connection_init"}"#).unwrap(),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
|
@ -101,13 +101,13 @@ mod test {
|
|||
},
|
||||
},
|
||||
serde_json::from_str(
|
||||
r##"{"type": "subscribe", "id": "foo", "payload": {
|
||||
r#"{"type": "subscribe", "id": "foo", "payload": {
|
||||
"query": "query MyQuery { __typename }",
|
||||
"variables": {
|
||||
"foo": "bar"
|
||||
},
|
||||
"operationName": "MyQuery"
|
||||
}}"##
|
||||
}}"#
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
|
@ -123,16 +123,16 @@ mod test {
|
|||
},
|
||||
},
|
||||
serde_json::from_str(
|
||||
r##"{"type": "subscribe", "id": "foo", "payload": {
|
||||
r#"{"type": "subscribe", "id": "foo", "payload": {
|
||||
"query": "query MyQuery { __typename }"
|
||||
}}"##
|
||||
}}"#
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
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(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -949,7 +949,7 @@ mod test {
|
|||
Output::Message(ServerMessage::Error { id, .. }) => {
|
||||
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),
|
||||
..
|
||||
}) => 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!(errors.len(), 1);
|
||||
}
|
||||
msg @ _ => panic!("expected data, got: {msg:?}"),
|
||||
msg => panic!("expected data, got: {msg:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,12 +121,12 @@ mod test {
|
|||
|
||||
assert_eq!(
|
||||
serde_json::to_string(&ServerMessage::ConnectionAck).unwrap(),
|
||||
r##"{"type":"connection_ack"}"##,
|
||||
r#"{"type":"connection_ack"}"#,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_string(&ServerMessage::Pong).unwrap(),
|
||||
r##"{"type":"pong"}"##,
|
||||
r#"{"type":"pong"}"#,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
|
@ -138,7 +138,7 @@ mod test {
|
|||
},
|
||||
})
|
||||
.unwrap(),
|
||||
r##"{"type":"next","id":"foo","payload":{"data":null}}"##,
|
||||
r#"{"type":"next","id":"foo","payload":{"data":null}}"#,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
|
@ -147,12 +147,12 @@ mod test {
|
|||
payload: GraphQLError::UnknownOperationName.into(),
|
||||
})
|
||||
.unwrap(),
|
||||
r##"{"type":"error","id":"foo","payload":[{"message":"Unknown operation"}]}"##,
|
||||
r#"{"type":"error","id":"foo","payload":[{"message":"Unknown operation"}]}"#,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_string(&ServerMessage::Complete { id: "foo".into() }).unwrap(),
|
||||
r##"{"type":"complete","id":"foo"}"##,
|
||||
r#"{"type":"complete","id":"foo"}"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ mod test {
|
|||
ClientMessage::ConnectionInit {
|
||||
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(),
|
||||
);
|
||||
|
||||
|
@ -73,7 +73,7 @@ mod test {
|
|||
ClientMessage::ConnectionInit {
|
||||
payload: graphql_vars! {},
|
||||
},
|
||||
serde_json::from_str(r##"{"type": "connection_init"}"##).unwrap(),
|
||||
serde_json::from_str(r#"{"type": "connection_init"}"#).unwrap(),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
|
@ -86,13 +86,13 @@ mod test {
|
|||
},
|
||||
},
|
||||
serde_json::from_str(
|
||||
r##"{"type": "start", "id": "foo", "payload": {
|
||||
r#"{"type": "start", "id": "foo", "payload": {
|
||||
"query": "query MyQuery { __typename }",
|
||||
"variables": {
|
||||
"foo": "bar"
|
||||
},
|
||||
"operationName": "MyQuery"
|
||||
}}"##
|
||||
}}"#
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
|
@ -107,21 +107,21 @@ mod test {
|
|||
},
|
||||
},
|
||||
serde_json::from_str(
|
||||
r##"{"type": "start", "id": "foo", "payload": {
|
||||
r#"{"type": "start", "id": "foo", "payload": {
|
||||
"query": "query MyQuery { __typename }"
|
||||
}}"##
|
||||
}}"#
|
||||
)
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
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!(
|
||||
ClientMessage::ConnectionTerminate,
|
||||
serde_json::from_str(r##"{"type": "connection_terminate"}"##).unwrap(),
|
||||
serde_json::from_str(r#"{"type": "connection_terminate"}"#).unwrap(),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -876,7 +876,7 @@ mod test {
|
|||
ServerMessage::Error { id, .. } => {
|
||||
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),
|
||||
..
|
||||
}) => 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!(errors.len(), 1);
|
||||
}
|
||||
msg @ _ => panic!("expected data, got: {msg:?}"),
|
||||
msg => panic!("expected data, got: {msg:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,12 +144,12 @@ mod test {
|
|||
},
|
||||
})
|
||||
.unwrap(),
|
||||
r##"{"type":"connection_error","payload":{"message":"foo"}}"##,
|
||||
r#"{"type":"connection_error","payload":{"message":"foo"}}"#,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_string(&ServerMessage::ConnectionAck).unwrap(),
|
||||
r##"{"type":"connection_ack"}"##,
|
||||
r#"{"type":"connection_ack"}"#,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
|
@ -161,7 +161,7 @@ mod test {
|
|||
},
|
||||
})
|
||||
.unwrap(),
|
||||
r##"{"type":"data","id":"foo","payload":{"data":null}}"##,
|
||||
r#"{"type":"data","id":"foo","payload":{"data":null}}"#,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
|
@ -170,17 +170,17 @@ mod test {
|
|||
payload: GraphQLError::UnknownOperationName.into(),
|
||||
})
|
||||
.unwrap(),
|
||||
r##"{"type":"error","id":"foo","payload":[{"message":"Unknown operation"}]}"##,
|
||||
r#"{"type":"error","id":"foo","payload":[{"message":"Unknown operation"}]}"#,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_string(&ServerMessage::Complete { id: "foo".into() }).unwrap(),
|
||||
r##"{"type":"complete","id":"foo"}"##,
|
||||
r#"{"type":"complete","id":"foo"}"#,
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
serde_json::to_string(&ServerMessage::ConnectionKeepAlive).unwrap(),
|
||||
r##"{"type":"ka"}"##,
|
||||
r#"{"type":"ka"}"#,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -325,7 +325,9 @@ mod tests {
|
|||
impl http_tests::HttpIntegration for TestHyperIntegration {
|
||||
fn get(&self, url: &str) -> http_tests::TestResponse {
|
||||
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 {
|
||||
|
@ -336,7 +338,7 @@ mod tests {
|
|||
.header(reqwest::header::CONTENT_TYPE, "application/json")
|
||||
.body(body.to_owned())
|
||||
.send()
|
||||
.expect(&format!("failed POST {url}"));
|
||||
.unwrap_or_else(|_| panic!("failed POST {url}"));
|
||||
make_test_response(res)
|
||||
}
|
||||
|
||||
|
@ -348,7 +350,7 @@ mod tests {
|
|||
.header(reqwest::header::CONTENT_TYPE, "application/graphql")
|
||||
.body(body.to_owned())
|
||||
.send()
|
||||
.expect(&format!("failed POST {url}"));
|
||||
.unwrap_or_else(|_| panic!("failed POST {url}"));
|
||||
make_test_response(res)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ fn get_graphql_handler(
|
|||
request: juniper_rocket::GraphQLRequest,
|
||||
schema: &State<Schema>,
|
||||
) -> juniper_rocket::GraphQLResponse {
|
||||
request.execute_sync(&*schema, &*context)
|
||||
request.execute_sync(schema, context)
|
||||
}
|
||||
|
||||
#[rocket::post("/graphql", data = "<request>")]
|
||||
|
@ -26,7 +26,7 @@ fn post_graphql_handler(
|
|||
request: juniper_rocket::GraphQLRequest,
|
||||
schema: &State<Schema>,
|
||||
) -> juniper_rocket::GraphQLResponse {
|
||||
request.execute_sync(&*schema, &*context)
|
||||
request.execute_sync(schema, context)
|
||||
}
|
||||
|
||||
#[rocket::main]
|
||||
|
|
|
@ -490,8 +490,6 @@ mod fromform_tests {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
use futures;
|
||||
|
||||
use juniper::{
|
||||
http::tests as http_tests,
|
||||
tests::fixtures::starwars::schema::{Database, Query},
|
||||
|
@ -512,7 +510,7 @@ mod tests {
|
|||
request: super::GraphQLRequest,
|
||||
schema: &State<Schema>,
|
||||
) -> super::GraphQLResponse {
|
||||
request.execute_sync(&*schema, &*context)
|
||||
request.execute_sync(schema, context)
|
||||
}
|
||||
|
||||
#[post("/", data = "<request>")]
|
||||
|
@ -521,7 +519,7 @@ mod tests {
|
|||
request: super::GraphQLRequest,
|
||||
schema: &State<Schema>,
|
||||
) -> super::GraphQLResponse {
|
||||
request.execute_sync(&*schema, &*context)
|
||||
request.execute_sync(schema, context)
|
||||
}
|
||||
|
||||
struct TestRocketIntegration {
|
||||
|
@ -570,7 +568,7 @@ mod tests {
|
|||
schema: &State<Schema>,
|
||||
) -> super::GraphQLResponse {
|
||||
assert_eq!(request.operation_names(), vec![Some("TestQuery")]);
|
||||
request.execute_sync(&*schema, &*context)
|
||||
request.execute_sync(schema, context)
|
||||
}
|
||||
|
||||
let rocket = make_rocket_without_routes()
|
||||
|
|
|
@ -35,7 +35,7 @@ async fn main() {
|
|||
|
||||
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());
|
||||
|
||||
warp::serve(
|
||||
|
|
|
@ -641,7 +641,7 @@ mod tests {
|
|||
.path("/graphql2")
|
||||
.header("accept", "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)
|
||||
.await;
|
||||
|
||||
|
@ -681,10 +681,10 @@ mod tests {
|
|||
.header("accept", "application/json")
|
||||
.header("content-type", "application/json")
|
||||
.body(
|
||||
r##"[
|
||||
r#"[
|
||||
{ "variables": null, "query": "{ hero(episode: NEW_HOPE) { name } }" },
|
||||
{ "variables": null, "query": "{ hero(episode: EMPIRE) { id name } }" }
|
||||
]"##,
|
||||
]"#,
|
||||
)
|
||||
.reply(&filter)
|
||||
.await;
|
||||
|
@ -734,7 +734,7 @@ mod tests_http_harness {
|
|||
EmptyMutation::<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 {
|
||||
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: String = utf8_percent_encode(url.query().unwrap_or(""), QUERY_ENCODE_SET)
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>()
|
||||
.join("");
|
||||
|
||||
|
|
|
@ -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!(
|
||||
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!(
|
||||
value,
|
||||
|
|
|
@ -2419,10 +2419,11 @@ mod nullable_argument_subtyping {
|
|||
#[graphql_object(impl = CharacterValue)]
|
||||
impl Droid {
|
||||
fn id(&self, is_present: Option<bool>) -> &str {
|
||||
is_present
|
||||
.unwrap_or_default()
|
||||
.then_some(&*self.id)
|
||||
.unwrap_or("missing")
|
||||
if is_present.unwrap_or_default() {
|
||||
&self.id
|
||||
} else {
|
||||
"missing"
|
||||
}
|
||||
}
|
||||
|
||||
fn primary_function(&self) -> &str {
|
||||
|
|
|
@ -2527,7 +2527,7 @@ mod inferred_custom_context_from_field {
|
|||
&self.primary_function
|
||||
}
|
||||
|
||||
fn info<'b>(&'b self) -> &'b str {
|
||||
fn info(&self) -> &str {
|
||||
&self.primary_function
|
||||
}
|
||||
}
|
||||
|
@ -3246,10 +3246,11 @@ mod nullable_argument_subtyping {
|
|||
#[graphql_object(impl = CharacterValue)]
|
||||
impl Droid {
|
||||
fn id(&self, is_present: Option<bool>) -> &str {
|
||||
is_present
|
||||
.unwrap_or_default()
|
||||
.then_some(&*self.id)
|
||||
.unwrap_or("missing")
|
||||
if is_present.unwrap_or_default() {
|
||||
&self.id
|
||||
} else {
|
||||
"missing"
|
||||
}
|
||||
}
|
||||
|
||||
fn primary_function(&self) -> &str {
|
||||
|
|
|
@ -2439,10 +2439,11 @@ mod nullable_argument_subtyping {
|
|||
#[graphql_object(impl = CharacterValue)]
|
||||
impl Droid {
|
||||
fn id(&self, is_present: Option<bool>) -> &str {
|
||||
is_present
|
||||
.unwrap_or_default()
|
||||
.then_some(&*self.id)
|
||||
.unwrap_or("missing")
|
||||
if is_present.unwrap_or_default() {
|
||||
&self.id
|
||||
} else {
|
||||
"missing"
|
||||
}
|
||||
}
|
||||
|
||||
fn primary_function(&self) -> &str {
|
||||
|
|
|
@ -299,7 +299,7 @@ mod multiple_delegated_parse_token {
|
|||
fn from_input<S: ScalarValue>(v: &InputValue<S>) -> Result<StringOrInt, String> {
|
||||
v.as_string_value()
|
||||
.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}"))
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ mod trivial {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -90,7 +90,7 @@ mod trivial {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
|
||||
);
|
||||
|
@ -171,7 +171,7 @@ mod raw_method {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"myId": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -187,7 +187,7 @@ mod raw_method {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"async": "async-32"}), vec![])),
|
||||
);
|
||||
|
@ -249,7 +249,7 @@ mod ignored_method {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -311,7 +311,7 @@ mod fallible_method {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -327,7 +327,7 @@ mod fallible_method {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
|
||||
);
|
||||
|
@ -403,7 +403,7 @@ mod argument {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -419,7 +419,7 @@ mod argument {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"homePlanet": "earth,None"}), vec![])),
|
||||
);
|
||||
|
@ -547,7 +547,7 @@ mod default_argument {
|
|||
] {
|
||||
assert_eq!(
|
||||
resolve_into_stream(input, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({ "id": expected }), vec![])),
|
||||
);
|
||||
|
@ -564,7 +564,7 @@ mod default_argument {
|
|||
] {
|
||||
assert_eq!(
|
||||
resolve_into_stream(input, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({ "info": expected }), vec![])),
|
||||
);
|
||||
|
@ -660,7 +660,7 @@ mod generic {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": 34}), vec![])),
|
||||
);
|
||||
|
@ -682,7 +682,7 @@ mod generic {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -760,7 +760,7 @@ mod generic_lifetime {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": 34}), vec![])),
|
||||
);
|
||||
|
@ -782,7 +782,7 @@ mod generic_lifetime {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"planet": "earth"}), vec![])),
|
||||
);
|
||||
|
@ -804,7 +804,7 @@ mod generic_lifetime {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -826,7 +826,7 @@ mod generic_lifetime {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"planet": "mars"}), vec![])),
|
||||
);
|
||||
|
@ -928,7 +928,7 @@ mod deprecation_from_attr {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -944,7 +944,7 @@ mod deprecation_from_attr {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"a": "a"}), vec![])),
|
||||
);
|
||||
|
@ -960,7 +960,7 @@ mod deprecation_from_attr {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"b": "b"}), vec![])),
|
||||
);
|
||||
|
@ -1057,7 +1057,7 @@ mod explicit_name_description_and_deprecation {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"myId": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -1073,7 +1073,7 @@ mod explicit_name_description_and_deprecation {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"a": "a"}), vec![])),
|
||||
);
|
||||
|
@ -1089,7 +1089,7 @@ mod explicit_name_description_and_deprecation {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"b": "b"}), vec![])),
|
||||
);
|
||||
|
@ -1236,7 +1236,7 @@ mod renamed_all_fields_and_args {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -1252,7 +1252,7 @@ mod renamed_all_fields_and_args {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"home_planet": "earth"}), vec![])),
|
||||
);
|
||||
|
@ -1268,7 +1268,7 @@ mod renamed_all_fields_and_args {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"async_info": 3}), vec![])),
|
||||
);
|
||||
|
@ -1329,7 +1329,7 @@ mod explicit_scalar {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -1345,7 +1345,7 @@ mod explicit_scalar {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
|
||||
);
|
||||
|
@ -1380,7 +1380,7 @@ mod custom_scalar {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -1396,7 +1396,7 @@ mod custom_scalar {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
|
||||
);
|
||||
|
@ -1431,7 +1431,7 @@ mod explicit_generic_scalar {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -1447,7 +1447,7 @@ mod explicit_generic_scalar {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
|
||||
);
|
||||
|
@ -1482,7 +1482,7 @@ mod bounded_generic_scalar {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "human-32"}), vec![])),
|
||||
);
|
||||
|
@ -1498,7 +1498,7 @@ mod bounded_generic_scalar {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"homePlanet": "earth"}), vec![])),
|
||||
);
|
||||
|
@ -1551,7 +1551,7 @@ mod explicit_custom_context {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "ctx!"}), vec![])),
|
||||
);
|
||||
|
@ -1568,7 +1568,7 @@ mod explicit_custom_context {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"info": "human being"}), vec![])),
|
||||
);
|
||||
|
@ -1585,7 +1585,7 @@ mod explicit_custom_context {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"more": "ctx!"}), vec![])),
|
||||
);
|
||||
|
@ -1638,7 +1638,7 @@ mod inferred_custom_context_from_field {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "ctx!"}), vec![])),
|
||||
);
|
||||
|
@ -1655,7 +1655,7 @@ mod inferred_custom_context_from_field {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"info": "human being"}), vec![])),
|
||||
);
|
||||
|
@ -1672,7 +1672,7 @@ mod inferred_custom_context_from_field {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &ctx)
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"more": "ctx!"}), vec![])),
|
||||
);
|
||||
|
@ -1724,7 +1724,7 @@ mod executor {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"id": "id"}), vec![])),
|
||||
);
|
||||
|
@ -1740,7 +1740,7 @@ mod executor {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"info": "input!"}), vec![])),
|
||||
);
|
||||
|
@ -1756,7 +1756,7 @@ mod executor {
|
|||
|
||||
assert_eq!(
|
||||
resolve_into_stream(DOC, None, &schema, &graphql_vars! {}, &())
|
||||
.then(|s| extract_next(s))
|
||||
.then(extract_next)
|
||||
.await,
|
||||
Ok((graphql_value!({"info2": "no info"}), vec![])),
|
||||
);
|
||||
|
|
|
@ -70,13 +70,13 @@ mod trivial {
|
|||
|
||||
impl Character for Human {
|
||||
fn as_human(&self) -> Option<&Human> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Character for 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 {
|
||||
fn as_human(&self) -> Option<&Human> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<A, B> Character<A, B> for Droid {
|
||||
fn as_droid(&self) -> Option<&Droid> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ mod description_from_doc_comment {
|
|||
|
||||
impl Character for Human {
|
||||
fn as_human(&self) -> Option<&Human> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,7 +383,7 @@ mod explicit_name_and_description {
|
|||
|
||||
impl Character for Human {
|
||||
fn as_human(&self) -> Option<&Human> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -474,13 +474,13 @@ mod explicit_scalar {
|
|||
|
||||
impl Character for Human {
|
||||
fn as_human(&self) -> Option<&Human> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Character for Droid {
|
||||
fn as_droid(&self) -> Option<&Droid> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -565,13 +565,13 @@ mod custom_scalar {
|
|||
|
||||
impl Character for Human {
|
||||
fn as_human(&self) -> Option<&Human> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Character for 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 {
|
||||
fn as_human(&self) -> Option<&Human> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: ScalarValue> Character<S> for Droid {
|
||||
fn as_droid(&self) -> Option<&Droid> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -743,13 +743,13 @@ mod bounded_generic_scalar {
|
|||
|
||||
impl Character for Human {
|
||||
fn as_human(&self) -> Option<&Human> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Character for Droid {
|
||||
fn as_droid(&self) -> Option<&Droid> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -832,13 +832,13 @@ mod explicit_custom_context {
|
|||
|
||||
impl Character for HumanCustomContext {
|
||||
fn as_human(&self) -> Option<&HumanCustomContext> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Character for DroidCustomContext {
|
||||
fn as_droid(&self) -> Option<&DroidCustomContext> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -919,13 +919,13 @@ mod inferred_custom_context {
|
|||
|
||||
impl Character for HumanCustomContext {
|
||||
fn as_human(&self, _: &CustomContext) -> Option<&HumanCustomContext> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl Character for DroidCustomContext {
|
||||
fn as_droid(&self, _: &()) -> Option<&DroidCustomContext> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1009,7 +1009,7 @@ mod ignored_method {
|
|||
|
||||
impl Character for Human {
|
||||
fn as_human(&self) -> Option<&Human> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1084,7 +1084,7 @@ mod external_resolver {
|
|||
|
||||
impl Character for Human {
|
||||
fn as_human(&self) -> Option<&Human> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1197,19 +1197,19 @@ mod full_featured {
|
|||
|
||||
impl<T> Character<T> for HumanCustomContext {
|
||||
fn as_human(&self, _: &()) -> Option<&HumanCustomContext> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Character<T> for DroidCustomContext {
|
||||
fn as_droid(&self) -> Option<&DroidCustomContext> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Character<T> for EwokCustomContext {
|
||||
fn as_ewok(&self) -> Option<&EwokCustomContext> {
|
||||
Some(&self)
|
||||
Some(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ impl TestSubscriptionType {
|
|||
|
||||
async fn run_variable_query<F>(query: &str, vars: Variables<MyScalarValue>, f: F)
|
||||
where
|
||||
F: Fn(&Object<MyScalarValue>) -> (),
|
||||
F: Fn(&Object<MyScalarValue>),
|
||||
{
|
||||
let schema =
|
||||
RootNode::new_with_scalar_value(TestType, EmptyMutation::<()>::new(), TestSubscriptionType);
|
||||
|
@ -83,7 +83,7 @@ where
|
|||
|
||||
async fn run_query<F>(query: &str, f: F)
|
||||
where
|
||||
F: Fn(&Object<MyScalarValue>) -> (),
|
||||
F: Fn(&Object<MyScalarValue>),
|
||||
{
|
||||
run_variable_query(query, graphql_vars! {}, f).await;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ async fn explicit_null() {
|
|||
};
|
||||
|
||||
assert_eq!(
|
||||
juniper::execute(query, None, &schema, &vars, &Context).await,
|
||||
juniper::execute(query, None, schema, &vars, &Context).await,
|
||||
Ok((
|
||||
graphql_value!({
|
||||
"literalOneIsExplicitNull": false,
|
||||
|
|
|
@ -29,7 +29,7 @@ struct SubscriptionsRoot;
|
|||
#[graphql_subscription(name = "Subscription")]
|
||||
impl SubscriptionsRoot {
|
||||
async fn users() -> Result<BoxStream<'static, User>, Error> {
|
||||
Ok(users_stream()?)
|
||||
users_stream()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ async fn query_document_can_be_pre_parsed() {
|
|||
.await
|
||||
.unwrap();
|
||||
|
||||
assert!(errors.len() == 0);
|
||||
assert!(errors.is_empty());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
@ -85,8 +85,8 @@ async fn subscription_document_can_be_pre_parsed() {
|
|||
|
||||
let mut stream = resolve_validated_subscription(
|
||||
&document,
|
||||
&operation,
|
||||
&root_node,
|
||||
operation,
|
||||
root_node,
|
||||
&graphql_vars! {},
|
||||
&Context,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue