Formatting...
This commit is contained in:
parent
3c8e796cfe
commit
2e011014ea
38 changed files with 119 additions and 126 deletions
|
@ -1,9 +1,9 @@
|
|||
#[cfg(test)]
|
||||
use fnv::FnvHashMap;
|
||||
|
||||
use juniper::{self, FromInputValue, GraphQLType, InputValue, ToInputValue};
|
||||
use juniper::GraphQLInputObject;
|
||||
use juniper::DefaultScalarValue;
|
||||
use juniper::GraphQLInputObject;
|
||||
use juniper::{self, FromInputValue, GraphQLType, InputValue, ToInputValue};
|
||||
|
||||
#[derive(GraphQLInputObject, Debug, PartialEq)]
|
||||
#[graphql(
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#[cfg(test)]
|
||||
use fnv::FnvHashMap;
|
||||
use juniper::DefaultScalarValue;
|
||||
use juniper::GraphQLObject;
|
||||
#[cfg(test)]
|
||||
use juniper::Object;
|
||||
use juniper::GraphQLObject;
|
||||
|
||||
#[cfg(test)]
|
||||
use juniper::{self, execute, EmptyMutation, GraphQLType, RootNode, Value, Variables};
|
||||
|
|
|
@ -391,9 +391,9 @@ mod tests {
|
|||
use crate::ast::Document;
|
||||
use crate::parser::UnlocatedParseResult;
|
||||
use crate::schema::model::SchemaType;
|
||||
use std::collections::HashMap;
|
||||
use crate::validation::test_harness::{MutationRoot, QueryRoot};
|
||||
use crate::value::{DefaultScalarValue, ScalarRefValue, ScalarValue};
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn parse_document_source<S>(q: &str) -> UnlocatedParseResult<Document<S>>
|
||||
where
|
||||
|
|
|
@ -789,10 +789,8 @@ where
|
|||
|
||||
fn insert_placeholder(&mut self, name: Name, of_type: Type<'r>) {
|
||||
if !self.types.contains_key(&name) {
|
||||
self.types.insert(
|
||||
name,
|
||||
MetaType::Placeholder(PlaceholderMeta { of_type }),
|
||||
);
|
||||
self.types
|
||||
.insert(name, MetaType::Placeholder(PlaceholderMeta { of_type }));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ where
|
|||
{
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let (result, errs) = crate::execute(query, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(query, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ where
|
|||
{
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let (result, errs) = crate::execute(query, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(query, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
|
|
@ -65,7 +65,8 @@ mod field_execution {
|
|||
.into_iter()
|
||||
.collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -161,7 +162,8 @@ mod merge_parallel_fragments {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -258,7 +260,8 @@ mod merge_parallel_inline_fragments {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -457,7 +460,8 @@ mod dynamic_context_switching {
|
|||
.collect(),
|
||||
};
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &ctx).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &ctx).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -513,7 +517,8 @@ mod dynamic_context_switching {
|
|||
.collect(),
|
||||
};
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &ctx).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &ctx).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, vec![]);
|
||||
|
||||
|
@ -566,7 +571,8 @@ mod dynamic_context_switching {
|
|||
.collect(),
|
||||
};
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &ctx).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &ctx).expect("Execution failed");
|
||||
|
||||
assert_eq!(
|
||||
errs,
|
||||
|
@ -614,7 +620,8 @@ mod dynamic_context_switching {
|
|||
.collect(),
|
||||
};
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &ctx).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &ctx).expect("Execution failed");
|
||||
|
||||
assert_eq!(
|
||||
errs,
|
||||
|
@ -674,7 +681,8 @@ mod dynamic_context_switching {
|
|||
.collect(),
|
||||
};
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &ctx).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &ctx).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -749,7 +757,8 @@ mod propagates_errors_to_nullable_fields {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
println!("Result: {:#?}", result);
|
||||
|
||||
|
@ -775,7 +784,8 @@ mod propagates_errors_to_nullable_fields {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
println!("Result: {:#?}", result);
|
||||
|
||||
|
@ -798,7 +808,8 @@ mod propagates_errors_to_nullable_fields {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
println!("Result: {:#?}", result);
|
||||
|
||||
|
@ -821,7 +832,8 @@ mod propagates_errors_to_nullable_fields {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
println!("Result: {:#?}", result);
|
||||
|
||||
|
@ -847,7 +859,8 @@ mod propagates_errors_to_nullable_fields {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
println!("Result: {:#?}", result);
|
||||
|
||||
|
@ -870,7 +883,8 @@ mod propagates_errors_to_nullable_fields {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
println!("Result: {:#?}", result);
|
||||
|
||||
|
@ -896,7 +910,8 @@ mod propagates_errors_to_nullable_fields {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
println!("Result: {:#?}", result);
|
||||
|
||||
|
@ -919,7 +934,8 @@ mod propagates_errors_to_nullable_fields {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
println!("Result: {:#?}", result);
|
||||
|
||||
|
@ -980,7 +996,8 @@ mod named_operations {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -997,7 +1014,8 @@ mod named_operations {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -1014,8 +1032,8 @@ mod named_operations {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) =
|
||||
crate::execute(doc, Some("OtherExample"), &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) = crate::execute(doc, Some("OtherExample"), &schema, &vars, &())
|
||||
.expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
|
|
@ -107,7 +107,8 @@ mod interface {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
@ -241,7 +242,8 @@ mod union {
|
|||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
|
|
@ -122,7 +122,8 @@ where
|
|||
{
|
||||
let schema = RootNode::new(TestType, EmptyMutation::<()>::new());
|
||||
|
||||
let (result, errs) = crate::execute(query, None, &schema, &vars, &()).expect("Execution failed");
|
||||
let (result, errs) =
|
||||
crate::execute(query, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
assert_eq!(errs, []);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ pub mod playground;
|
|||
|
||||
use serde::de::Deserialize;
|
||||
use serde::ser::{self, Serialize, SerializeMap};
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::ast::InputValue;
|
||||
use crate::executor::ExecutionError;
|
||||
|
|
|
@ -111,13 +111,14 @@ graphql_scalar!(NaiveDateTime where Scalar = <S> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use chrono::prelude::*;
|
||||
use crate::{value::DefaultScalarValue, InputValue};
|
||||
use chrono::prelude::*;
|
||||
|
||||
fn datetime_fixedoffset_test(raw: &'static str) {
|
||||
let input: crate::InputValue<DefaultScalarValue> = InputValue::scalar(raw.to_string());
|
||||
|
||||
let parsed: DateTime<FixedOffset> = crate::FromInputValue::from_input_value(&input).unwrap();
|
||||
let parsed: DateTime<FixedOffset> =
|
||||
crate::FromInputValue::from_input_value(&input).unwrap();
|
||||
let expected = DateTime::parse_from_rfc3339(raw).unwrap();
|
||||
|
||||
assert_eq!(parsed, expected);
|
||||
|
|
|
@ -399,10 +399,10 @@ where
|
|||
mod tests {
|
||||
use super::{ExecutionError, GraphQLError};
|
||||
use crate::ast::InputValue;
|
||||
use serde_json::from_str;
|
||||
use serde_json::to_string;
|
||||
use crate::value::{DefaultScalarValue, Object};
|
||||
use crate::{FieldError, Value};
|
||||
use serde_json::from_str;
|
||||
use serde_json::to_string;
|
||||
|
||||
#[test]
|
||||
fn int() {
|
||||
|
|
|
@ -22,8 +22,8 @@ graphql_scalar!(Url where Scalar = <S>{
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use url::Url;
|
||||
use crate::InputValue;
|
||||
use url::Url;
|
||||
|
||||
#[test]
|
||||
fn url_from_input_value() {
|
||||
|
|
|
@ -29,8 +29,8 @@ graphql_scalar!(Uuid where Scalar = <S> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use uuid::Uuid;
|
||||
use crate::{value::DefaultScalarValue, InputValue};
|
||||
use uuid::Uuid;
|
||||
|
||||
#[test]
|
||||
fn uuid_from_input_value() {
|
||||
|
|
|
@ -498,10 +498,7 @@ where
|
|||
Ok(Spanning::start_end(
|
||||
&start_pos,
|
||||
&arguments.as_ref().map_or(&name.end, |s| &s.end).clone(),
|
||||
Directive {
|
||||
name,
|
||||
arguments,
|
||||
},
|
||||
Directive { name, arguments },
|
||||
))
|
||||
}
|
||||
|
||||
|
|
|
@ -190,10 +190,9 @@ impl<'a> Lexer<'a> {
|
|||
|
||||
fn scan_name(&mut self) -> LexerResult<'a> {
|
||||
let start_pos = self.position;
|
||||
let (start_idx, start_ch) = self.next_char().ok_or_else(|| Spanning::zero_width(
|
||||
&self.position,
|
||||
LexerError::UnexpectedEndOfFile,
|
||||
))?;
|
||||
let (start_idx, start_ch) = self
|
||||
.next_char()
|
||||
.ok_or_else(|| Spanning::zero_width(&self.position, LexerError::UnexpectedEndOfFile))?;
|
||||
assert!(is_name_start(start_ch));
|
||||
|
||||
let mut end_idx = start_idx;
|
||||
|
@ -216,10 +215,9 @@ impl<'a> Lexer<'a> {
|
|||
|
||||
fn scan_string(&mut self) -> LexerResult<'a> {
|
||||
let start_pos = self.position;
|
||||
let (start_idx, start_ch) = self.next_char().ok_or_else(|| Spanning::zero_width(
|
||||
&self.position,
|
||||
LexerError::UnexpectedEndOfFile,
|
||||
))?;
|
||||
let (start_idx, start_ch) = self
|
||||
.next_char()
|
||||
.ok_or_else(|| Spanning::zero_width(&self.position, LexerError::UnexpectedEndOfFile))?;
|
||||
if start_ch != '"' {
|
||||
return Err(Spanning::zero_width(
|
||||
&self.position,
|
||||
|
@ -279,18 +277,16 @@ impl<'a> Lexer<'a> {
|
|||
&mut self,
|
||||
start_pos: &SourcePosition,
|
||||
) -> Result<(), Spanning<LexerError>> {
|
||||
let (start_idx, _) = self.peek_char().ok_or_else(|| Spanning::zero_width(
|
||||
&self.position,
|
||||
LexerError::UnterminatedString,
|
||||
))?;
|
||||
let (start_idx, _) = self
|
||||
.peek_char()
|
||||
.ok_or_else(|| Spanning::zero_width(&self.position, LexerError::UnterminatedString))?;
|
||||
let mut end_idx = start_idx;
|
||||
let mut len = 0;
|
||||
|
||||
for _ in 0..4 {
|
||||
let (idx, ch) = self.next_char().ok_or_else(|| Spanning::zero_width(
|
||||
&self.position,
|
||||
LexerError::UnterminatedString,
|
||||
))?;
|
||||
let (idx, ch) = self.next_char().ok_or_else(|| {
|
||||
Spanning::zero_width(&self.position, LexerError::UnterminatedString)
|
||||
})?;
|
||||
|
||||
if !ch.is_alphanumeric() {
|
||||
break;
|
||||
|
@ -328,10 +324,9 @@ impl<'a> Lexer<'a> {
|
|||
|
||||
fn scan_number(&mut self) -> LexerResult<'a> {
|
||||
let start_pos = self.position;
|
||||
let (start_idx, _) = self.peek_char().ok_or_else(|| Spanning::zero_width(
|
||||
&self.position,
|
||||
LexerError::UnexpectedEndOfFile,
|
||||
))?;
|
||||
let (start_idx, _) = self
|
||||
.peek_char()
|
||||
.ok_or_else(|| Spanning::zero_width(&self.position, LexerError::UnexpectedEndOfFile))?;
|
||||
|
||||
let mut last_idx = start_idx;
|
||||
let mut last_char = '1';
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use indexmap::IndexMap;
|
||||
|
||||
use juniper_codegen::{
|
||||
GraphQLInputObjectInternal as GraphQLInputObject,
|
||||
GraphQLEnumInternal as GraphQLEnum,
|
||||
GraphQLEnumInternal as GraphQLEnum, GraphQLInputObjectInternal as GraphQLInputObject,
|
||||
};
|
||||
|
||||
use crate::ast::{FromInputValue, InputValue, Type};
|
||||
|
|
|
@ -60,10 +60,7 @@ impl<T> Spanning<T> {
|
|||
|
||||
#[doc(hidden)]
|
||||
pub fn spanning(v: Vec<Spanning<T>>) -> Option<Spanning<Vec<Spanning<T>>>> {
|
||||
if let (Some(start), Some(end)) = (
|
||||
v.first().map(|s| s.start),
|
||||
v.last().map(|s| s.end),
|
||||
) {
|
||||
if let (Some(start), Some(end)) = (v.first().map(|s| s.start), v.last().map(|s| s.end)) {
|
||||
Some(Spanning {
|
||||
item: v,
|
||||
start,
|
||||
|
@ -98,11 +95,7 @@ impl SourcePosition {
|
|||
pub fn new(index: usize, line: usize, col: usize) -> SourcePosition {
|
||||
assert!(index >= line + col);
|
||||
|
||||
SourcePosition {
|
||||
index,
|
||||
line,
|
||||
col,
|
||||
}
|
||||
SourcePosition { index, line, col }
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
use crate::ast::InputValue;
|
||||
|
||||
use crate::parser::{ParseError, ParseResult, Parser, ScalarToken, SourcePosition, Spanning, Token};
|
||||
use crate::parser::{
|
||||
ParseError, ParseResult, Parser, ScalarToken, SourcePosition, Spanning, Token,
|
||||
};
|
||||
use crate::schema::meta::{InputObjectMeta, MetaType};
|
||||
use crate::schema::model::SchemaType;
|
||||
use crate::value::ScalarValue;
|
||||
|
|
|
@ -780,12 +780,7 @@ fn clean_docstring(multiline: &[&str]) -> Option<String> {
|
|||
.iter()
|
||||
.enumerate()
|
||||
.flat_map(|(line, ln)| {
|
||||
let new_ln = if !ln
|
||||
.chars()
|
||||
.next()
|
||||
.map(char::is_whitespace)
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let new_ln = if !ln.chars().next().map(char::is_whitespace).unwrap_or(false) {
|
||||
ln.trim_end() // skip trimming the first line
|
||||
} else if ln.len() >= trim_start {
|
||||
ln[trim_start..].trim_end()
|
||||
|
|
|
@ -6,7 +6,9 @@ use juniper_codegen::GraphQLEnumInternal as GraphQLEnum;
|
|||
|
||||
use crate::ast::Type;
|
||||
use crate::executor::{Context, Registry};
|
||||
use crate::schema::meta::{Argument, InterfaceMeta, MetaType, ObjectMeta, PlaceholderMeta, UnionMeta};
|
||||
use crate::schema::meta::{
|
||||
Argument, InterfaceMeta, MetaType, ObjectMeta, PlaceholderMeta, UnionMeta,
|
||||
};
|
||||
use crate::types::base::GraphQLType;
|
||||
use crate::types::name::Name;
|
||||
use crate::value::{DefaultScalarValue, ScalarRefValue, ScalarValue};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#![allow(missing_docs)]
|
||||
|
||||
use std::collections::HashMap;
|
||||
use juniper_codegen::GraphQLEnumInternal as GraphQLEnum;
|
||||
use std::collections::HashMap;
|
||||
|
||||
#[derive(GraphQLEnum, Copy, Clone, Eq, PartialEq, Debug)]
|
||||
pub enum Episode {
|
||||
|
|
|
@ -480,11 +480,11 @@ where
|
|||
sub_exec.push_error_at(e, start_pos.clone());
|
||||
}
|
||||
} else if !resolve_selection_set_into(
|
||||
instance,
|
||||
info,
|
||||
&fragment.selection_set[..],
|
||||
&sub_exec,
|
||||
result,
|
||||
instance,
|
||||
info,
|
||||
&fragment.selection_set[..],
|
||||
&sub_exec,
|
||||
result,
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::ast::InputValue;
|
||||
use crate::schema::meta::{EnumMeta, InputObjectMeta, MetaType};
|
||||
use crate::schema::model::{SchemaType, TypeType};
|
||||
use std::collections::HashSet;
|
||||
use crate::value::ScalarValue;
|
||||
use std::collections::HashSet;
|
||||
|
||||
pub fn is_valid_literal_value<S>(
|
||||
schema: &SchemaType<S>,
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::ast::{Directive, Field, InputValue};
|
||||
use crate::parser::Spanning;
|
||||
use crate::schema::meta::Argument;
|
||||
use std::fmt::Debug;
|
||||
use crate::types::utilities::is_valid_literal_value;
|
||||
use crate::validation::{ValidatorContext, Visitor};
|
||||
use crate::value::ScalarValue;
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub struct ArgumentsOfCorrectType<'a, S: Debug + 'a> {
|
||||
current_args: Option<&'a Vec<Argument<'a, S>>>,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
use crate::ast::{Directive, Field, InputValue};
|
||||
use crate::parser::Spanning;
|
||||
use crate::schema::meta::Argument;
|
||||
use std::fmt::Debug;
|
||||
use crate::validation::{ValidatorContext, Visitor};
|
||||
use crate::value::ScalarValue;
|
||||
use std::fmt::Debug;
|
||||
|
||||
#[derive(Debug)]
|
||||
enum ArgumentPosition<'a> {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
use crate::ast::{Directive, Field, Fragment, FragmentSpread, InlineFragment, Operation, OperationType};
|
||||
use crate::ast::{
|
||||
Directive, Field, Fragment, FragmentSpread, InlineFragment, Operation, OperationType,
|
||||
};
|
||||
use crate::parser::Spanning;
|
||||
use crate::schema::model::DirectiveLocation;
|
||||
use crate::validation::{ValidatorContext, Visitor};
|
||||
|
@ -121,10 +123,7 @@ where
|
|||
}
|
||||
}
|
||||
} else {
|
||||
ctx.report_error(
|
||||
&unknown_error_message(directive_name),
|
||||
&[directive.start],
|
||||
);
|
||||
ctx.report_error(&unknown_error_message(directive_name), &[directive.start]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,7 @@ where
|
|||
) {
|
||||
let spread_name = &spread.item.name;
|
||||
if !context.is_known_fragment(spread_name.item) {
|
||||
context.report_error(
|
||||
&error_message(spread_name.item),
|
||||
&[spread_name.start],
|
||||
);
|
||||
context.report_error(&error_message(spread_name.item), &[spread_name.start]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::ast::{Fragment, InlineFragment, VariableDefinition};
|
||||
use crate::parser::{SourcePosition, Spanning};
|
||||
use std::fmt::Debug;
|
||||
use crate::validation::{ValidatorContext, Visitor};
|
||||
use crate::value::ScalarValue;
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub struct KnownTypeNames;
|
||||
|
||||
|
|
|
@ -24,9 +24,9 @@ mod variables_are_input_types;
|
|||
mod variables_in_allowed_position;
|
||||
|
||||
use crate::ast::Document;
|
||||
use std::fmt::Debug;
|
||||
use crate::validation::{visit, MultiVisitorNil, ValidatorContext};
|
||||
use crate::value::ScalarValue;
|
||||
use std::fmt::Debug;
|
||||
|
||||
pub(crate) fn visit_all_rules<'a, S: Debug>(ctx: &mut ValidatorContext<'a, S>, doc: &'a Document<S>)
|
||||
where
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::ast::{Document, Fragment, FragmentSpread, InputValue, Operation, VariableDefinition};
|
||||
use crate::parser::{SourcePosition, Spanning};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use crate::validation::{RuleError, ValidatorContext, Visitor};
|
||||
use crate::value::ScalarValue;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Scope<'a> {
|
||||
|
@ -75,10 +75,7 @@ where
|
|||
unused
|
||||
.into_iter()
|
||||
.map(|var| {
|
||||
RuleError::new(
|
||||
&error_message(var.item, *op_name),
|
||||
&[var.start, *pos],
|
||||
)
|
||||
RuleError::new(&error_message(var.item, *op_name), &[var.start, *pos])
|
||||
})
|
||||
.collect(),
|
||||
);
|
||||
|
@ -143,9 +140,7 @@ where
|
|||
.item
|
||||
.referenced_variables()
|
||||
.iter()
|
||||
.map(|&var_name| {
|
||||
Spanning::start_end(&value.start, &value.end, var_name)
|
||||
})
|
||||
.map(|&var_name| Spanning::start_end(&value.start, &value.end, var_name))
|
||||
.collect(),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::ast::{Document, Fragment, FragmentSpread, InputValue, Operation, VariableDefinition};
|
||||
use crate::parser::Spanning;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use crate::validation::{RuleError, ValidatorContext, Visitor};
|
||||
use crate::value::ScalarValue;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub enum Scope<'a> {
|
||||
|
@ -75,9 +75,7 @@ where
|
|||
def_vars
|
||||
.iter()
|
||||
.filter(|var| !used.contains(var.item))
|
||||
.map(|var| {
|
||||
RuleError::new(&error_message(var.item, *op_name), &[var.start])
|
||||
})
|
||||
.map(|var| RuleError::new(&error_message(var.item, *op_name), &[var.start]))
|
||||
.collect(),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
use crate::ast::{Arguments, Definition, Document, Field, Fragment, FragmentSpread, Selection, Type};
|
||||
use crate::ast::{
|
||||
Arguments, Definition, Document, Field, Fragment, FragmentSpread, Selection, Type,
|
||||
};
|
||||
use crate::parser::{SourcePosition, Spanning};
|
||||
use crate::schema::meta::{Field as FieldType, MetaType};
|
||||
use crate::validation::{ValidatorContext, Visitor};
|
||||
use crate::value::ScalarValue;
|
||||
use std::borrow::Borrow;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
use crate::validation::{ValidatorContext, Visitor};
|
||||
use crate::value::ScalarValue;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Conflict(ConflictReason, Vec<SourcePosition>, Vec<SourcePosition>);
|
||||
|
|
|
@ -3,9 +3,9 @@ use std::fmt::Debug;
|
|||
use crate::ast::{Definition, Document, FragmentSpread, InlineFragment};
|
||||
use crate::parser::Spanning;
|
||||
use crate::schema::meta::MetaType;
|
||||
use std::collections::HashMap;
|
||||
use crate::validation::{ValidatorContext, Visitor};
|
||||
use crate::value::ScalarValue;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct PossibleFragmentSpreads<'a, S: Debug + 'a> {
|
||||
fragment_types: HashMap<&'a str, &'a MetaType<'a, S>>,
|
||||
|
|
|
@ -27,10 +27,7 @@ where
|
|||
if let Some(ref op_name) = op.item.name {
|
||||
match self.names.entry(op_name.item) {
|
||||
Entry::Occupied(e) => {
|
||||
ctx.report_error(
|
||||
&error_message(op_name.item),
|
||||
&[e.get().clone(), op.start],
|
||||
);
|
||||
ctx.report_error(&error_message(op_name.item), &[e.get().clone(), op.start]);
|
||||
}
|
||||
Entry::Vacant(e) => {
|
||||
e.insert(op.start);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::parser::{ParseError, ScalarToken};
|
||||
use juniper_codegen::GraphQLScalarValueInternal as GraphQLScalarValue;
|
||||
use serde::de;
|
||||
use serde::ser::Serialize;
|
||||
use std::fmt::{self, Debug, Display};
|
||||
use juniper_codegen::GraphQLScalarValueInternal as GraphQLScalarValue;
|
||||
|
||||
/// The result of converting a string into a scalar value
|
||||
pub type ParseScalarResult<'a, S = DefaultScalarValue> = Result<S, ParseError<'a>>;
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::str::FromStr;
|
|||
|
||||
use proc_macro2::{Span, TokenStream};
|
||||
use quote::{quote, ToTokens};
|
||||
use syn::{self, Data, DeriveInput, Field, Fields, Ident, Meta, NestedMeta, parse_quote};
|
||||
use syn::{self, parse_quote, Data, DeriveInput, Field, Fields, Ident, Meta, NestedMeta};
|
||||
|
||||
use crate::util::*;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use proc_macro2::{Span, TokenStream};
|
||||
use syn::{self, Data, DeriveInput, Field, Fields, Ident, parse_quote};
|
||||
use quote::quote;
|
||||
use syn::{self, parse_quote, Data, DeriveInput, Field, Fields, Ident};
|
||||
|
||||
use crate::util::*;
|
||||
|
||||
|
|
Loading…
Reference in a new issue