From 483ca6b7eb01327bab1a4c2115af0d6f1d0e109d Mon Sep 17 00:00:00 2001 From: Sunli Date: Sun, 6 Sep 2020 18:38:06 +0800 Subject: [PATCH] Make all tests pass. --- benchmark/src/lib.rs | 2 +- src/schema.rs | 1 - src/validation/rules/upload_file.rs | 15 +++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/benchmark/src/lib.rs b/benchmark/src/lib.rs index d6462c9b..92949747 100644 --- a/benchmark/src/lib.rs +++ b/benchmark/src/lib.rs @@ -1,6 +1,6 @@ pub use async_graphql::http::GQLResponse; use async_graphql::{ObjectType, QueryResponse, Schema, SubscriptionType}; -use async_graphql_parser::{parse_query, query::Document}; +use async_graphql_parser::{parse_query, types::Document}; use async_std::task; #[cfg(feature = "jemalloc")] diff --git a/src/schema.rs b/src/schema.rs index 3198c4c2..c347180f 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -12,7 +12,6 @@ use crate::{ CacheControl, Error, ObjectType, Pos, QueryEnv, QueryError, QueryResponse, Result, SubscriptionType, Type, Variables, ID, }; -use bytes::Bytes; use futures::channel::mpsc; use futures::Stream; use indexmap::map::IndexMap; diff --git a/src/validation/rules/upload_file.rs b/src/validation/rules/upload_file.rs index 75c79ae1..4aac5b80 100644 --- a/src/validation/rules/upload_file.rs +++ b/src/validation/rules/upload_file.rs @@ -1,4 +1,4 @@ -use crate::parser::types::OperationDefinition; +use crate::parser::types::{OperationDefinition, OperationType}; use crate::validation::visitor::{Visitor, VisitorContext}; use crate::Positioned; @@ -16,11 +16,14 @@ impl<'a> Visitor<'a> for UploadFile { .registry .concrete_type_by_parsed_type(&var.node.var_type.node) { - if ty.name() == "Upload" { - ctx.report_error( - vec![var.pos], - "The Upload type is only allowed to be defined on a mutation", - ); + if operation_definition.node.ty != OperationType::Mutation && ty.name() == "Upload" + { + if ty.name() == "Upload" { + ctx.report_error( + vec![var.pos], + "The Upload type is only allowed to be defined on a mutation", + ); + } } } }