Make all tests pass.

This commit is contained in:
Sunli 2020-09-06 18:38:06 +08:00
parent e50f1c9200
commit 483ca6b7eb
3 changed files with 10 additions and 8 deletions

View File

@ -1,6 +1,6 @@
pub use async_graphql::http::GQLResponse; pub use async_graphql::http::GQLResponse;
use async_graphql::{ObjectType, QueryResponse, Schema, SubscriptionType}; 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; use async_std::task;
#[cfg(feature = "jemalloc")] #[cfg(feature = "jemalloc")]

View File

@ -12,7 +12,6 @@ use crate::{
CacheControl, Error, ObjectType, Pos, QueryEnv, QueryError, QueryResponse, Result, CacheControl, Error, ObjectType, Pos, QueryEnv, QueryError, QueryResponse, Result,
SubscriptionType, Type, Variables, ID, SubscriptionType, Type, Variables, ID,
}; };
use bytes::Bytes;
use futures::channel::mpsc; use futures::channel::mpsc;
use futures::Stream; use futures::Stream;
use indexmap::map::IndexMap; use indexmap::map::IndexMap;

View File

@ -1,4 +1,4 @@
use crate::parser::types::OperationDefinition; use crate::parser::types::{OperationDefinition, OperationType};
use crate::validation::visitor::{Visitor, VisitorContext}; use crate::validation::visitor::{Visitor, VisitorContext};
use crate::Positioned; use crate::Positioned;
@ -16,11 +16,14 @@ impl<'a> Visitor<'a> for UploadFile {
.registry .registry
.concrete_type_by_parsed_type(&var.node.var_type.node) .concrete_type_by_parsed_type(&var.node.var_type.node)
{ {
if ty.name() == "Upload" { if operation_definition.node.ty != OperationType::Mutation && ty.name() == "Upload"
ctx.report_error( {
vec![var.pos], if ty.name() == "Upload" {
"The Upload type is only allowed to be defined on a mutation", ctx.report_error(
); vec![var.pos],
"The Upload type is only allowed to be defined on a mutation",
);
}
} }
} }
} }