Skip to content

Commit c358d5e

Browse files
committed
Make the executor and validation APIs public to enable splitting parsing and execution into two stages
Based on #773 (comment) and #773 (comment)
1 parent 5248371 commit c358d5e

File tree

8 files changed

+17
-6
lines changed

8 files changed

+17
-6
lines changed

juniper/src/ast.rs

+2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ pub enum OperationType {
119119
Subscription,
120120
}
121121

122+
#[allow(missing_docs)]
122123
#[derive(Clone, PartialEq, Debug)]
123124
pub struct Operation<'a, S> {
124125
pub operation_type: OperationType,
@@ -142,6 +143,7 @@ pub enum Definition<'a, S> {
142143
Fragment(Spanning<Fragment<'a, S>>),
143144
}
144145

146+
#[doc(hidden)]
145147
pub type Document<'a, S> = Vec<Definition<'a, S>>;
146148

147149
/// Parse an unstructured input value into a Rust data type.

juniper/src/executor/look_ahead.rs

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ where
9696
}
9797
}
9898

99+
#[doc(hidden)]
99100
#[derive(Debug, Clone, PartialEq)]
100101
pub struct ChildSelection<'a, S: 'a> {
101102
pub(super) inner: LookAheadSelection<'a, S>,

juniper/src/executor/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Resolve the document to values
2+
13
use std::{
24
borrow::Cow,
35
cmp::Ordering,
@@ -54,6 +56,7 @@ pub struct Registry<'r, S = DefaultScalarValue> {
5456
pub types: FnvHashMap<Name, MetaType<'r, S>>,
5557
}
5658

59+
#[allow(missing_docs)]
5760
#[derive(Clone)]
5861
pub enum FieldPath<'a> {
5962
Root(SourcePosition),
@@ -979,6 +982,7 @@ where
979982
Ok((value, errors))
980983
}
981984

985+
#[doc(hidden)]
982986
pub fn get_operation<'b, 'd, 'e, S>(
983987
document: &'b Document<'d, S>,
984988
operation_name: Option<&str>,

juniper/src/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ mod value;
119119
#[macro_use]
120120
mod macros;
121121
mod ast;
122-
mod executor;
122+
pub mod executor;
123123
mod introspection;
124124
pub mod parser;
125125
pub(crate) mod schema;
126126
mod types;
127127
mod util;
128-
mod validation;
128+
pub mod validation;
129129
// This needs to be public until docs have support for private modules:
130130
// https://github.com/rust-lang/cargo/issues/1520
131131
pub mod http;
@@ -145,12 +145,12 @@ pub use crate::util::to_camel_case;
145145
use crate::{
146146
executor::{execute_validated_query, get_operation},
147147
introspection::{INTROSPECTION_QUERY, INTROSPECTION_QUERY_WITHOUT_DESCRIPTIONS},
148-
parser::{parse_document_source, ParseError, Spanning},
148+
parser::parse_document_source,
149149
validation::{validate_input_values, visit_all_rules, ValidatorContext},
150150
};
151151

152152
pub use crate::{
153-
ast::{FromInputValue, InputValue, Selection, ToInputValue, Type},
153+
ast::{Document, FromInputValue, InputValue, Operation, Selection, ToInputValue, Type},
154154
executor::{
155155
Applies, Context, ExecutionError, ExecutionResult, Executor, FieldError, FieldResult,
156156
FromContext, IntoFieldError, IntoResolvable, LookAheadArgument, LookAheadMethods,
@@ -161,6 +161,7 @@ pub use crate::{
161161
subscription::{ExtractTypeFromStream, IntoFieldResult},
162162
AsDynGraphQLValue,
163163
},
164+
parser::{ParseError, Spanning},
164165
schema::{
165166
meta,
166167
model::{RootNode, SchemaType},

juniper/src/validation/input_value.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ enum Path<'a> {
1919
ObjectField(&'a str, &'a Path<'a>),
2020
}
2121

22+
#[doc(hidden)]
2223
pub fn validate_input_values<S>(
2324
values: &Variables<S>,
2425
operation: &Spanning<Operation<S>>,

juniper/src/validation/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ mod visitor;
1010
#[cfg(test)]
1111
pub(crate) mod test_harness;
1212

13-
pub(crate) use self::rules::visit_all_rules;
13+
pub use self::rules::visit_all_rules;
1414
pub use self::{
1515
context::{RuleError, ValidatorContext},
1616
input_value::validate_input_values,

juniper/src/validation/multi_visitor.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::{
1111
#[doc(hidden)]
1212
pub struct MultiVisitorNil;
1313

14+
#[doc(hidden)]
1415
impl MultiVisitorNil {
1516
pub fn with<V>(self, visitor: V) -> MultiVisitorCons<V, Self> {
1617
MultiVisitorCons(visitor, self)

juniper/src/validation/rules/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ use crate::{
3030
};
3131
use std::fmt::Debug;
3232

33-
pub(crate) fn visit_all_rules<'a, S: Debug>(ctx: &mut ValidatorContext<'a, S>, doc: &'a Document<S>)
33+
#[doc(hidden)]
34+
pub fn visit_all_rules<'a, S: Debug>(ctx: &mut ValidatorContext<'a, S>, doc: &'a Document<S>)
3435
where
3536
S: ScalarValue,
3637
{

0 commit comments

Comments
 (0)