Small improvements + rustfmt

This commit is contained in:
Georg Semmler 2018-03-15 15:43:16 +01:00 committed by Magnus Hallin
parent dd99914fbe
commit 61c07b95fc
2 changed files with 590 additions and 631 deletions

File diff suppressed because it is too large Load diff

View file

@ -11,6 +11,10 @@ use ast::{Definition, Document, Fragment, FromInputValue, InputValue, OperationT
use parser::SourcePosition;
use value::Value;
use GraphQLError;
use ast::{Definition, Document, Fragment, FromInputValue, InputValue, OperationType,
Selection, ToInputValue, Type};
use value::Value;
use parser::SourcePosition;
use schema::meta::{Argument, EnumMeta, EnumValue, Field, InputObjectMeta, InterfaceMeta, ListMeta,
MetaType, NullableMeta, ObjectMeta, PlaceholderMeta, ScalarMeta, UnionMeta};
@ -50,6 +54,7 @@ where
fragments: &'a HashMap<&'a str, &'a Fragment<'a>>,
variables: &'a Variables,
current_selection_set: Option<&'a [Selection<'a>]>,
parent_selection_set: Option<&'a [Selection<'a>]>,
current_type: TypeType<'a>,
schema: &'a SchemaType<'a>,
context: &'a CtxT,
@ -319,6 +324,7 @@ impl<'a, CtxT> Executor<'a, CtxT> {
fragments: self.fragments,
variables: self.variables,
current_selection_set: self.current_selection_set,
parent_selection_set: self.parent_selection_set,
current_type: self.current_type.clone(),
schema: self.schema,
context: ctx,
@ -340,6 +346,7 @@ impl<'a, CtxT> Executor<'a, CtxT> {
fragments: self.fragments,
variables: self.variables,
current_selection_set: selection_set,
parent_selection_set: self.current_selection_set,
current_type: self.schema.make_type(
&self.current_type
.innermost_concrete()
@ -351,7 +358,7 @@ impl<'a, CtxT> Executor<'a, CtxT> {
context: self.context,
errors: self.errors,
field_path: FieldPath::Field(field_alias, location, &self.field_path),
type_name: self.type_name
type_name: self.type_name,
}
}
@ -365,6 +372,7 @@ impl<'a, CtxT> Executor<'a, CtxT> {
fragments: self.fragments,
variables: self.variables,
current_selection_set: selection_set,
parent_selection_set: self.current_selection_set,
current_type: match type_name {
Some(type_name) => self.schema.type_by_name(type_name).expect("Type not found"),
None => self.current_type.clone(),
@ -430,16 +438,20 @@ impl<'a, CtxT> Executor<'a, CtxT> {
});
}
pub fn look_ahead(&self) -> LookAheadSelection {
LookAheadSelection{
name: self.type_name,
alias: None,
arguments: Vec::new(),
childs: self.current_selection_set.map(|s| s.iter().map(|s| ChildSelection {
inner: LookAheadSelection::build_from_selection(s, self.variables, self.fragments),
applies_for: Applies::All
}).collect()).unwrap_or_else(Vec::new)
}
pub fn look_ahead(&'a self) -> LookAheadSelection<'a> {
self.parent_selection_set.map(|p| {
LookAheadSelection::build_from_selection(&p[0], self.variables, self.fragments)
}).unwrap_or_else(||{
LookAheadSelection{
name: self.current_type.innermost_concrete().name().unwrap_or(""),
alias: None,
arguments: Vec::new(),
childs: self.current_selection_set.map(|s| s.iter().map(|s| ChildSelection {
inner: LookAheadSelection::build_from_selection(s, self.variables, self.fragments),
applies_for: Applies::All
}).collect()).unwrap_or_else(Vec::new)
}
})
}
}
@ -568,6 +580,7 @@ where
.collect(),
variables: final_vars,
current_selection_set: Some(&op.item.selection_set[..]),
parent_selection_set: None,
current_type: root_type,
schema: &root_node.schema,
context: context,