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;
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")]

View File

@ -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;

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::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",
);
}
}
}
}