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