chore: Remove ScalarRefValue trait
The trait was introduced while introducing generic scalars, but is not actually required or useful. It's functionality is fully covered by methods on the `ScalarValue` trait. It also forced a lof of for<'a> ScalarRefValue bounds all over the code, complicating signatures a lot. It is completely removed now.
This commit is contained in:
parent
eb85fefc36
commit
36c71d7162
41 changed files with 137 additions and 521 deletions
|
@ -5,7 +5,7 @@ use indexmap::IndexMap;
|
||||||
use crate::{
|
use crate::{
|
||||||
executor::Variables,
|
executor::Variables,
|
||||||
parser::Spanning,
|
parser::Spanning,
|
||||||
value::{DefaultScalarValue, ScalarRefValue, ScalarValue},
|
value::{DefaultScalarValue, ScalarValue},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A type literal in the syntax tree
|
/// A type literal in the syntax tree
|
||||||
|
@ -152,9 +152,7 @@ pub type Document<'a, S> = Vec<Definition<'a, S>>;
|
||||||
/// Must be implemented manually when manually exposing new enums or scalars.
|
/// Must be implemented manually when manually exposing new enums or scalars.
|
||||||
pub trait FromInputValue<S = DefaultScalarValue>: Sized {
|
pub trait FromInputValue<S = DefaultScalarValue>: Sized {
|
||||||
/// Performs the conversion.
|
/// Performs the conversion.
|
||||||
fn from_input_value(v: &InputValue<S>) -> Option<Self>
|
fn from_input_value(v: &InputValue<S>) -> Option<Self>;
|
||||||
where
|
|
||||||
for<'b> &'b S: ScalarRefValue<'b>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Losslessly clones a Rust data type into an InputValue.
|
/// Losslessly clones a Rust data type into an InputValue.
|
||||||
|
@ -316,7 +314,6 @@ where
|
||||||
pub fn convert<T>(&self) -> Option<T>
|
pub fn convert<T>(&self) -> Option<T>
|
||||||
where
|
where
|
||||||
T: FromInputValue<S>,
|
T: FromInputValue<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
<T as FromInputValue<S>>::from_input_value(self)
|
<T as FromInputValue<S>>::from_input_value(self)
|
||||||
}
|
}
|
||||||
|
@ -346,30 +343,18 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// View the underlying int value, if present.
|
/// View the underlying int value, if present.
|
||||||
#[deprecated(since = "0.11.0", note = "Use `InputValue::as_scalar_value` instead")]
|
pub fn as_int_value<'a>(&'a self) -> Option<i32> {
|
||||||
pub fn as_int_value<'a>(&'a self) -> Option<i32>
|
self.as_scalar_value().and_then(|s| s.as_int())
|
||||||
where
|
|
||||||
&'a S: Into<Option<&'a i32>>,
|
|
||||||
{
|
|
||||||
self.as_scalar_value().cloned()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// View the underlying float value, if present.
|
/// View the underlying float value, if present.
|
||||||
#[deprecated(since = "0.11.0", note = "Use `InputValue::as_scalar_value` instead")]
|
pub fn as_float_value<'a>(&'a self) -> Option<f64> {
|
||||||
pub fn as_float_value<'a>(&'a self) -> Option<f64>
|
self.as_scalar_value().and_then(|s| s.as_float())
|
||||||
where
|
|
||||||
&'a S: Into<Option<&'a f64>>,
|
|
||||||
{
|
|
||||||
self.as_scalar_value().cloned()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// View the underlying string value, if present.
|
/// View the underlying string value, if present.
|
||||||
#[deprecated(since = "0.11.0", note = "Use `InputValue::as_scalar_value` instead")]
|
pub fn as_string_value<'a>(&'a self) -> Option<&'a str> {
|
||||||
pub fn as_string_value<'a>(&'a self) -> Option<&'a str>
|
self.as_scalar_value().and_then(|s| s.as_str())
|
||||||
where
|
|
||||||
&'a S: Into<Option<&'a String>>,
|
|
||||||
{
|
|
||||||
self.as_scalar_value().map(|s| s as &str)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// View the underlying scalar value, if present.
|
/// View the underlying scalar value, if present.
|
||||||
|
@ -459,13 +444,17 @@ where
|
||||||
impl<S> fmt::Display for InputValue<S>
|
impl<S> fmt::Display for InputValue<S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
InputValue::Null => write!(f, "null"),
|
InputValue::Null => write!(f, "null"),
|
||||||
InputValue::Scalar(ref s) if s.is_type::<String>() => write!(f, "\"{}\"", s),
|
InputValue::Scalar(ref s) => {
|
||||||
InputValue::Scalar(ref s) => write!(f, "{}", s),
|
if let Some(s) = s.as_str() {
|
||||||
|
write!(f, "\"{}\"", s)
|
||||||
|
} else {
|
||||||
|
write!(f, "{}", s)
|
||||||
|
}
|
||||||
|
}
|
||||||
InputValue::Enum(ref v) => write!(f, "{}", v),
|
InputValue::Enum(ref v) => write!(f, "{}", v),
|
||||||
InputValue::Variable(ref v) => write!(f, "${}", v),
|
InputValue::Variable(ref v) => write!(f, "${}", v),
|
||||||
InputValue::List(ref v) => {
|
InputValue::List(ref v) => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{Directive, Fragment, InputValue, Selection},
|
ast::{Directive, Fragment, InputValue, Selection},
|
||||||
parser::Spanning,
|
parser::Spanning,
|
||||||
value::{ScalarRefValue, ScalarValue},
|
value::ScalarValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
@ -117,7 +117,6 @@ pub struct LookAheadSelection<'a, S: 'a> {
|
||||||
impl<'a, S> Default for LookAheadSelection<'a, S>
|
impl<'a, S> Default for LookAheadSelection<'a, S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
&'a S: ScalarRefValue<'a>,
|
|
||||||
{
|
{
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
LookAheadSelection {
|
LookAheadSelection {
|
||||||
|
@ -132,7 +131,6 @@ where
|
||||||
impl<'a, S> LookAheadSelection<'a, S>
|
impl<'a, S> LookAheadSelection<'a, S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
&'a S: ScalarRefValue<'a>,
|
|
||||||
{
|
{
|
||||||
fn should_include<'b, 'c>(
|
fn should_include<'b, 'c>(
|
||||||
directives: Option<&'b Vec<Spanning<Directive<S>>>>,
|
directives: Option<&'b Vec<Spanning<Directive<S>>>>,
|
||||||
|
@ -157,9 +155,7 @@ where
|
||||||
if let LookAheadValue::Scalar(s) =
|
if let LookAheadValue::Scalar(s) =
|
||||||
LookAheadValue::from_input_value(&v.item, vars)
|
LookAheadValue::from_input_value(&v.item, vars)
|
||||||
{
|
{
|
||||||
<&S as Into<Option<&bool>>>::into(s)
|
s.as_boolean().unwrap_or(false)
|
||||||
.cloned()
|
|
||||||
.unwrap_or(false)
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -174,9 +170,7 @@ where
|
||||||
if let LookAheadValue::Scalar(b) =
|
if let LookAheadValue::Scalar(b) =
|
||||||
LookAheadValue::from_input_value(&v.item, vars)
|
LookAheadValue::from_input_value(&v.item, vars)
|
||||||
{
|
{
|
||||||
<&S as Into<Option<&bool>>>::into(b)
|
b.as_boolean().map(::std::ops::Not::not).unwrap_or(false)
|
||||||
.map(::std::ops::Not::not)
|
|
||||||
.unwrap_or(false)
|
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
@ -439,14 +433,13 @@ mod tests {
|
||||||
parser::UnlocatedParseResult,
|
parser::UnlocatedParseResult,
|
||||||
schema::model::SchemaType,
|
schema::model::SchemaType,
|
||||||
validation::test_harness::{MutationRoot, QueryRoot},
|
validation::test_harness::{MutationRoot, QueryRoot},
|
||||||
value::{DefaultScalarValue, ScalarRefValue, ScalarValue},
|
value::{DefaultScalarValue, ScalarValue},
|
||||||
};
|
};
|
||||||
use std::collections::HashMap;
|
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
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
crate::parse_document_source(q, &SchemaType::new::<QueryRoot, MutationRoot>(&(), &()))
|
crate::parse_document_source(q, &SchemaType::new::<QueryRoot, MutationRoot>(&(), &()))
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ use crate::schema::{
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
types::{base::GraphQLType, name::Name},
|
types::{base::GraphQLType, name::Name},
|
||||||
value::{DefaultScalarValue, ParseScalarValue, ScalarRefValue, ScalarValue},
|
value::{DefaultScalarValue, ParseScalarValue, ScalarValue},
|
||||||
};
|
};
|
||||||
|
|
||||||
mod look_ahead;
|
mod look_ahead;
|
||||||
|
@ -235,7 +235,6 @@ impl<S> IntoFieldError<S> for FieldError<S> {
|
||||||
pub trait IntoResolvable<'a, S, T: GraphQLType<S>, C>: Sized
|
pub trait IntoResolvable<'a, S, T: GraphQLType<S>, C>: Sized
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
fn into(self, ctx: &'a C) -> FieldResult<Option<(&'a T::Context, T)>, S>;
|
fn into(self, ctx: &'a C) -> FieldResult<Option<(&'a T::Context, T)>, S>;
|
||||||
|
@ -246,7 +245,6 @@ where
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T::Context: FromContext<C>,
|
T::Context: FromContext<C>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn into(self, ctx: &'a C) -> FieldResult<Option<(&'a T::Context, T)>, S> {
|
fn into(self, ctx: &'a C) -> FieldResult<Option<(&'a T::Context, T)>, S> {
|
||||||
Ok(Some((FromContext::from(ctx), self)))
|
Ok(Some((FromContext::from(ctx), self)))
|
||||||
|
@ -258,7 +256,6 @@ where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
T::Context: FromContext<C>,
|
T::Context: FromContext<C>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn into(self, ctx: &'a C) -> FieldResult<Option<(&'a T::Context, T)>, S> {
|
fn into(self, ctx: &'a C) -> FieldResult<Option<(&'a T::Context, T)>, S> {
|
||||||
self.map(|v: T| Some((<T::Context as FromContext<C>>::from(ctx), v)))
|
self.map(|v: T| Some((<T::Context as FromContext<C>>::from(ctx), v)))
|
||||||
|
@ -270,7 +267,6 @@ impl<'a, S, T, C> IntoResolvable<'a, S, T, C> for (&'a T::Context, T)
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, T)>, S> {
|
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, T)>, S> {
|
||||||
Ok(Some(self))
|
Ok(Some(self))
|
||||||
|
@ -281,7 +277,6 @@ impl<'a, S, T, C> IntoResolvable<'a, S, Option<T>, C> for Option<(&'a T::Context
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, Option<T>)>, S> {
|
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, Option<T>)>, S> {
|
||||||
Ok(self.map(|(ctx, v)| (ctx, Some(v))))
|
Ok(self.map(|(ctx, v)| (ctx, Some(v))))
|
||||||
|
@ -292,7 +287,6 @@ impl<'a, S, T, C> IntoResolvable<'a, S, T, C> for FieldResult<(&'a T::Context, T
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, T)>, S> {
|
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, T)>, S> {
|
||||||
self.map(Some)
|
self.map(Some)
|
||||||
|
@ -304,7 +298,6 @@ impl<'a, S, T, C> IntoResolvable<'a, S, Option<T>, C>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, Option<T>)>, S> {
|
fn into(self, _: &'a C) -> FieldResult<Option<(&'a T::Context, Option<T>)>, S> {
|
||||||
self.map(|o| o.map(|(ctx, v)| (ctx, Some(v))))
|
self.map(|o| o.map(|(ctx, v)| (ctx, Some(v))))
|
||||||
|
@ -352,7 +345,6 @@ where
|
||||||
impl<'a, CtxT, S> Executor<'a, CtxT, S>
|
impl<'a, CtxT, S> Executor<'a, CtxT, S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
/// Resolve a single arbitrary value, mapping the context to a new type
|
/// Resolve a single arbitrary value, mapping the context to a new type
|
||||||
pub fn resolve_with_ctx<NewCtxT, T>(&self, info: &T::TypeInfo, value: &T) -> ExecutionResult<S>
|
pub fn resolve_with_ctx<NewCtxT, T>(&self, info: &T::TypeInfo, value: &T) -> ExecutionResult<S>
|
||||||
|
@ -671,7 +663,6 @@ where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
QueryT: GraphQLType<S, Context = CtxT>,
|
QueryT: GraphQLType<S, Context = CtxT>,
|
||||||
MutationT: GraphQLType<S, Context = CtxT>,
|
MutationT: GraphQLType<S, Context = CtxT>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let mut fragments = vec![];
|
let mut fragments = vec![];
|
||||||
let mut operation = None;
|
let mut operation = None;
|
||||||
|
@ -786,7 +777,6 @@ where
|
||||||
MutationT: crate::GraphQLTypeAsync<S, Context = CtxT> + Send + Sync,
|
MutationT: crate::GraphQLTypeAsync<S, Context = CtxT> + Send + Sync,
|
||||||
MutationT::TypeInfo: Send + Sync,
|
MutationT::TypeInfo: Send + Sync,
|
||||||
CtxT: Send + Sync,
|
CtxT: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let mut fragments = vec![];
|
let mut fragments = vec![];
|
||||||
let mut operation = None;
|
let mut operation = None;
|
||||||
|
@ -908,7 +898,6 @@ where
|
||||||
pub fn get_type<T>(&mut self, info: &T::TypeInfo) -> Type<'r>
|
pub fn get_type<T>(&mut self, info: &T::TypeInfo) -> Type<'r>
|
||||||
where
|
where
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
if let Some(name) = T::name(info) {
|
if let Some(name) = T::name(info) {
|
||||||
let validated_name = name.parse::<Name>().unwrap();
|
let validated_name = name.parse::<Name>().unwrap();
|
||||||
|
@ -930,7 +919,6 @@ where
|
||||||
pub fn field<T>(&mut self, name: &str, info: &T::TypeInfo) -> Field<'r, S>
|
pub fn field<T>(&mut self, name: &str, info: &T::TypeInfo) -> Field<'r, S>
|
||||||
where
|
where
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
Field {
|
Field {
|
||||||
name: name.to_owned(),
|
name: name.to_owned(),
|
||||||
|
@ -949,7 +937,6 @@ where
|
||||||
) -> Field<'r, S>
|
) -> Field<'r, S>
|
||||||
where
|
where
|
||||||
I: GraphQLType<S>,
|
I: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
Field {
|
Field {
|
||||||
name: name.to_owned(),
|
name: name.to_owned(),
|
||||||
|
@ -964,7 +951,6 @@ where
|
||||||
pub fn arg<T>(&mut self, name: &str, info: &T::TypeInfo) -> Argument<'r, S>
|
pub fn arg<T>(&mut self, name: &str, info: &T::TypeInfo) -> Argument<'r, S>
|
||||||
where
|
where
|
||||||
T: GraphQLType<S> + FromInputValue<S>,
|
T: GraphQLType<S> + FromInputValue<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
Argument::new(name, self.get_type::<T>(info))
|
Argument::new(name, self.get_type::<T>(info))
|
||||||
}
|
}
|
||||||
|
@ -981,7 +967,6 @@ where
|
||||||
) -> Argument<'r, S>
|
) -> Argument<'r, S>
|
||||||
where
|
where
|
||||||
T: GraphQLType<S> + ToInputValue<S> + FromInputValue<S>,
|
T: GraphQLType<S> + ToInputValue<S> + FromInputValue<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
Argument::new(name, self.get_type::<Option<T>>(info)).default_value(value.to_input_value())
|
Argument::new(name, self.get_type::<Option<T>>(info)).default_value(value.to_input_value())
|
||||||
}
|
}
|
||||||
|
@ -999,26 +984,22 @@ where
|
||||||
pub fn build_scalar_type<T>(&mut self, info: &T::TypeInfo) -> ScalarMeta<'r, S>
|
pub fn build_scalar_type<T>(&mut self, info: &T::TypeInfo) -> ScalarMeta<'r, S>
|
||||||
where
|
where
|
||||||
T: FromInputValue<S> + GraphQLType<S> + ParseScalarValue<S> + 'r,
|
T: FromInputValue<S> + GraphQLType<S> + ParseScalarValue<S> + 'r,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let name = T::name(info).expect("Scalar types must be named. Implement name()");
|
let name = T::name(info).expect("Scalar types must be named. Implement name()");
|
||||||
ScalarMeta::new::<T>(Cow::Owned(name.to_string()))
|
ScalarMeta::new::<T>(Cow::Owned(name.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a list meta type
|
/// Create a list meta type
|
||||||
pub fn build_list_type<T: GraphQLType<S>>(&mut self, info: &T::TypeInfo) -> ListMeta<'r>
|
pub fn build_list_type<T: GraphQLType<S>>(&mut self, info: &T::TypeInfo) -> ListMeta<'r> {
|
||||||
where
|
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
|
||||||
let of_type = self.get_type::<T>(info);
|
let of_type = self.get_type::<T>(info);
|
||||||
ListMeta::new(of_type)
|
ListMeta::new(of_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a nullable meta type
|
/// Create a nullable meta type
|
||||||
pub fn build_nullable_type<T: GraphQLType<S>>(&mut self, info: &T::TypeInfo) -> NullableMeta<'r>
|
pub fn build_nullable_type<T: GraphQLType<S>>(
|
||||||
where
|
&mut self,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
info: &T::TypeInfo,
|
||||||
{
|
) -> NullableMeta<'r> {
|
||||||
let of_type = self.get_type::<T>(info);
|
let of_type = self.get_type::<T>(info);
|
||||||
NullableMeta::new(of_type)
|
NullableMeta::new(of_type)
|
||||||
}
|
}
|
||||||
|
@ -1034,7 +1015,6 @@ where
|
||||||
) -> ObjectMeta<'r, S>
|
) -> ObjectMeta<'r, S>
|
||||||
where
|
where
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let name = T::name(info).expect("Object types must be named. Implement name()");
|
let name = T::name(info).expect("Object types must be named. Implement name()");
|
||||||
|
|
||||||
|
@ -1051,7 +1031,6 @@ where
|
||||||
) -> EnumMeta<'r, S>
|
) -> EnumMeta<'r, S>
|
||||||
where
|
where
|
||||||
T: FromInputValue<S> + GraphQLType<S>,
|
T: FromInputValue<S> + GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let name = T::name(info).expect("Enum types must be named. Implement name()");
|
let name = T::name(info).expect("Enum types must be named. Implement name()");
|
||||||
|
|
||||||
|
@ -1067,7 +1046,6 @@ where
|
||||||
) -> InterfaceMeta<'r, S>
|
) -> InterfaceMeta<'r, S>
|
||||||
where
|
where
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let name = T::name(info).expect("Interface types must be named. Implement name()");
|
let name = T::name(info).expect("Interface types must be named. Implement name()");
|
||||||
|
|
||||||
|
@ -1080,7 +1058,6 @@ where
|
||||||
pub fn build_union_type<T>(&mut self, info: &T::TypeInfo, types: &[Type<'r>]) -> UnionMeta<'r>
|
pub fn build_union_type<T>(&mut self, info: &T::TypeInfo, types: &[Type<'r>]) -> UnionMeta<'r>
|
||||||
where
|
where
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let name = T::name(info).expect("Union types must be named. Implement name()");
|
let name = T::name(info).expect("Union types must be named. Implement name()");
|
||||||
|
|
||||||
|
@ -1095,7 +1072,6 @@ where
|
||||||
) -> InputObjectMeta<'r, S>
|
) -> InputObjectMeta<'r, S>
|
||||||
where
|
where
|
||||||
T: FromInputValue<S> + GraphQLType<S>,
|
T: FromInputValue<S> + GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let name = T::name(info).expect("Input object types must be named. Implement name()");
|
let name = T::name(info).expect("Input object types must be named. Implement name()");
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use serde_derive::{Deserialize, Serialize};
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::InputValue,
|
ast::InputValue,
|
||||||
executor::ExecutionError,
|
executor::ExecutionError,
|
||||||
value::{DefaultScalarValue, ScalarRefValue, ScalarValue},
|
value::{DefaultScalarValue, ScalarValue},
|
||||||
FieldError, GraphQLError, GraphQLType, RootNode, Value, Variables,
|
FieldError, GraphQLError, GraphQLType, RootNode, Value, Variables,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,7 +83,6 @@ where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
QueryT: GraphQLType<S, Context = CtxT>,
|
QueryT: GraphQLType<S, Context = CtxT>,
|
||||||
MutationT: GraphQLType<S, Context = CtxT>,
|
MutationT: GraphQLType<S, Context = CtxT>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
GraphQLResponse(crate::execute(
|
GraphQLResponse(crate::execute(
|
||||||
&self.query,
|
&self.query,
|
||||||
|
@ -107,7 +106,6 @@ where
|
||||||
MutationT: crate::GraphQLTypeAsync<S, Context = CtxT> + Send + Sync,
|
MutationT: crate::GraphQLTypeAsync<S, Context = CtxT> + Send + Sync,
|
||||||
MutationT::TypeInfo: Send + Sync,
|
MutationT::TypeInfo: Send + Sync,
|
||||||
CtxT: Send + Sync,
|
CtxT: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let op = self.operation_name();
|
let op = self.operation_name();
|
||||||
let vars = &self.variables();
|
let vars = &self.variables();
|
||||||
|
|
|
@ -32,7 +32,7 @@ graphql_scalar!(DateTime<FixedOffset> as "DateTimeFixedOffset" where Scalar = <S
|
||||||
}
|
}
|
||||||
|
|
||||||
from_input_value(v: &InputValue) -> Option<DateTime<FixedOffset>> {
|
from_input_value(v: &InputValue) -> Option<DateTime<FixedOffset>> {
|
||||||
v.as_scalar_value::<String>()
|
v.as_string_value()
|
||||||
.and_then(|s| DateTime::parse_from_rfc3339(s).ok())
|
.and_then(|s| DateTime::parse_from_rfc3339(s).ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ graphql_scalar!(DateTime<Utc> as "DateTimeUtc" where Scalar = <S>{
|
||||||
}
|
}
|
||||||
|
|
||||||
from_input_value(v: &InputValue) -> Option<DateTime<Utc>> {
|
from_input_value(v: &InputValue) -> Option<DateTime<Utc>> {
|
||||||
v.as_scalar_value::<String>()
|
v.as_string_value()
|
||||||
.and_then(|s| (s.parse::<DateTime<Utc>>().ok()))
|
.and_then(|s| (s.parse::<DateTime<Utc>>().ok()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ graphql_scalar!(NaiveDate where Scalar = <S>{
|
||||||
}
|
}
|
||||||
|
|
||||||
from_input_value(v: &InputValue) -> Option<NaiveDate> {
|
from_input_value(v: &InputValue) -> Option<NaiveDate> {
|
||||||
v.as_scalar_value::<String>()
|
v.as_string_value()
|
||||||
.and_then(|s| NaiveDate::parse_from_str(s, "%Y-%m-%d").ok())
|
.and_then(|s| NaiveDate::parse_from_str(s, "%Y-%m-%d").ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,8 +102,8 @@ graphql_scalar!(NaiveDateTime where Scalar = <S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
from_input_value(v: &InputValue) -> Option<NaiveDateTime> {
|
from_input_value(v: &InputValue) -> Option<NaiveDateTime> {
|
||||||
v.as_scalar_value::<f64>()
|
v.as_float_value()
|
||||||
.and_then(|f| NaiveDateTime::from_timestamp_opt(*f as i64, 0))
|
.and_then(|f| NaiveDateTime::from_timestamp_opt(f as i64, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
from_str<'a>(value: ScalarToken<'a>) -> ParseScalarResult<'a, S> {
|
from_str<'a>(value: ScalarToken<'a>) -> ParseScalarResult<'a, S> {
|
||||||
|
|
|
@ -13,7 +13,7 @@ graphql_scalar!(Url where Scalar = <S>{
|
||||||
}
|
}
|
||||||
|
|
||||||
from_input_value(v: &InputValue) -> Option<Url> {
|
from_input_value(v: &InputValue) -> Option<Url> {
|
||||||
v.as_scalar_value::<String>()
|
v.as_string_value()
|
||||||
.and_then(|s| Url::parse(s).ok())
|
.and_then(|s| Url::parse(s).ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ graphql_scalar!(Uuid where Scalar = <S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
from_input_value(v: &InputValue) -> Option<Uuid> {
|
from_input_value(v: &InputValue) -> Option<Uuid> {
|
||||||
v.as_scalar_value::<String>()
|
v.as_string_value()
|
||||||
.and_then(|s| Uuid::parse_str(s).ok())
|
.and_then(|s| Uuid::parse_str(s).ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -170,10 +170,7 @@ pub use crate::{
|
||||||
scalars::{EmptyMutation, ID},
|
scalars::{EmptyMutation, ID},
|
||||||
},
|
},
|
||||||
validation::RuleError,
|
validation::RuleError,
|
||||||
value::{
|
value::{DefaultScalarValue, Object, ParseScalarResult, ParseScalarValue, ScalarValue, Value},
|
||||||
DefaultScalarValue, Object, ParseScalarResult, ParseScalarValue, ScalarRefValue,
|
|
||||||
ScalarValue, Value,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A pinned, boxed future that can be polled.
|
/// A pinned, boxed future that can be polled.
|
||||||
|
@ -204,7 +201,6 @@ pub fn execute<'a, S, CtxT, QueryT, MutationT>(
|
||||||
) -> Result<(Value<S>, Vec<ExecutionError<S>>), GraphQLError<'a>>
|
) -> Result<(Value<S>, Vec<ExecutionError<S>>), GraphQLError<'a>>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
QueryT: GraphQLType<S, Context = CtxT>,
|
QueryT: GraphQLType<S, Context = CtxT>,
|
||||||
MutationT: GraphQLType<S, Context = CtxT>,
|
MutationT: GraphQLType<S, Context = CtxT>,
|
||||||
{
|
{
|
||||||
|
@ -246,7 +242,6 @@ where
|
||||||
MutationT: GraphQLTypeAsync<S, Context = CtxT> + Send + Sync,
|
MutationT: GraphQLTypeAsync<S, Context = CtxT> + Send + Sync,
|
||||||
MutationT::TypeInfo: Send + Sync,
|
MutationT::TypeInfo: Send + Sync,
|
||||||
CtxT: Send + Sync,
|
CtxT: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let document = parse_document_source(document_source, &root_node.schema)?;
|
let document = parse_document_source(document_source, &root_node.schema)?;
|
||||||
{
|
{
|
||||||
|
@ -279,7 +274,6 @@ pub fn introspect<'a, S, CtxT, QueryT, MutationT>(
|
||||||
) -> Result<(Value<S>, Vec<ExecutionError<S>>), GraphQLError<'a>>
|
) -> Result<(Value<S>, Vec<ExecutionError<S>>), GraphQLError<'a>>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
QueryT: GraphQLType<S, Context = CtxT>,
|
QueryT: GraphQLType<S, Context = CtxT>,
|
||||||
MutationT: GraphQLType<S, Context = CtxT>,
|
MutationT: GraphQLType<S, Context = CtxT>,
|
||||||
{
|
{
|
||||||
|
|
|
@ -32,7 +32,6 @@ macro_rules! __juniper_impl_trait {
|
||||||
impl<$($other,)* $generic $(: $bound)*> $crate::$impl_trait<$generic> for $name
|
impl<$($other,)* $generic $(: $bound)*> $crate::$impl_trait<$generic> for $name
|
||||||
where
|
where
|
||||||
$generic: $crate::ScalarValue,
|
$generic: $crate::ScalarValue,
|
||||||
for<'__b> &'__b $generic: $crate::ScalarRefValue<'__b>,
|
|
||||||
{
|
{
|
||||||
$($body)*
|
$($body)*
|
||||||
}
|
}
|
||||||
|
@ -48,7 +47,6 @@ macro_rules! __juniper_impl_trait {
|
||||||
where
|
where
|
||||||
$($where)*
|
$($where)*
|
||||||
$generic: $crate::ScalarValue,
|
$generic: $crate::ScalarValue,
|
||||||
for<'__b> &'__b $generic: $crate::ScalarRefValue<'__b>,
|
|
||||||
{
|
{
|
||||||
$($body)*
|
$($body)*
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ macro_rules! graphql_interface {
|
||||||
info: &Self::TypeInfo,
|
info: &Self::TypeInfo,
|
||||||
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
||||||
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
||||||
where for<'__b> &'__b $crate::__juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
|
where
|
||||||
$crate::__juniper_insert_generic!($($scalar)+): 'r
|
$crate::__juniper_insert_generic!($($scalar)+): 'r
|
||||||
{
|
{
|
||||||
// Ensure all child types are registered
|
// Ensure all child types are registered
|
||||||
|
|
|
@ -8,8 +8,6 @@ mod object;
|
||||||
mod interface;
|
mod interface;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod scalar;
|
mod scalar;
|
||||||
#[macro_use]
|
|
||||||
mod union;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests;
|
mod tests;
|
||||||
|
|
|
@ -361,7 +361,7 @@ macro_rules! graphql_object {
|
||||||
info: &Self::TypeInfo,
|
info: &Self::TypeInfo,
|
||||||
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
||||||
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
||||||
where for<'__b> &'__b $crate::__juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
|
where
|
||||||
$crate::__juniper_insert_generic!($($scalar)+): 'r
|
$crate::__juniper_insert_generic!($($scalar)+): 'r
|
||||||
{
|
{
|
||||||
let fields = &[$(
|
let fields = &[$(
|
||||||
|
|
|
@ -90,7 +90,7 @@ macro_rules! graphql_scalar {
|
||||||
info: &Self::TypeInfo,
|
info: &Self::TypeInfo,
|
||||||
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
||||||
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
||||||
where for<'__b> &'__b $crate::__juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
|
where
|
||||||
$crate::__juniper_insert_generic!($($scalar)+): 'r
|
$crate::__juniper_insert_generic!($($scalar)+): 'r
|
||||||
{
|
{
|
||||||
let meta = registry.build_scalar_type::<Self>(info);
|
let meta = registry.build_scalar_type::<Self>(info);
|
||||||
|
@ -390,7 +390,7 @@ macro_rules! graphql_scalar {
|
||||||
info: &Self::TypeInfo,
|
info: &Self::TypeInfo,
|
||||||
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
||||||
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
||||||
where for<'__b> &'__b $crate::__juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
|
where
|
||||||
$crate::__juniper_insert_generic!($($scalar)+): 'r
|
$crate::__juniper_insert_generic!($($scalar)+): 'r
|
||||||
{
|
{
|
||||||
let meta = registry.build_scalar_type::<Self>(info);
|
let meta = registry.build_scalar_type::<Self>(info);
|
||||||
|
|
|
@ -73,17 +73,17 @@ impl Root {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: enable once [parameter attributes are supported by proc macros]
|
// TODO: enable once [parameter attributes are supported by proc macros]
|
||||||
// (https://github.com/graphql-rust/juniper/pull/441)
|
// (https://github.com/graphql-rust/juniper/pull/441)
|
||||||
// fn attr_arg_descr(
|
// fn attr_arg_descr(
|
||||||
// #[graphql(description = "The arg")]
|
// #[graphql(description = "The arg")]
|
||||||
// arg: i32) -> i32
|
// arg: i32) -> i32
|
||||||
// { 0 }
|
// { 0 }
|
||||||
// fn attr_arg_descr_collapse(
|
// fn attr_arg_descr_collapse(
|
||||||
// #[graphql(description = "The first arg")]
|
// #[graphql(description = "The first arg")]
|
||||||
// #[graphql(description = "and more details")]
|
// #[graphql(description = "and more details")]
|
||||||
// arg: i32,
|
// arg: i32,
|
||||||
// ) -> i32 { 0 }
|
// ) -> i32 { 0 }
|
||||||
|
|
||||||
#[graphql(arguments(arg(default = 123,),))]
|
#[graphql(arguments(arg(default = 123,),))]
|
||||||
fn arg_with_default(arg: i32) -> i32 {
|
fn arg_with_default(arg: i32) -> i32 {
|
||||||
|
|
|
@ -27,7 +27,7 @@ graphql_scalar!(DefaultName where Scalar = <S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
from_input_value(v: &InputValue) -> Option<DefaultName> {
|
from_input_value(v: &InputValue) -> Option<DefaultName> {
|
||||||
v.as_scalar_value::<i32>().map(|i| DefaultName(*i))
|
v.as_scalar_value().and_then(|s| s.as_int()).map(|i| DefaultName(i))
|
||||||
}
|
}
|
||||||
|
|
||||||
from_str<'a>(value: ScalarToken<'a>) -> ParseScalarResult<'a, S> {
|
from_str<'a>(value: ScalarToken<'a>) -> ParseScalarResult<'a, S> {
|
||||||
|
|
|
@ -1,143 +0,0 @@
|
||||||
/*
|
|
||||||
*
|
|
||||||
/**
|
|
||||||
Expose GraphQL unions
|
|
||||||
|
|
||||||
Like interfaces, mapping unions can be tricky in idiomatic Rust. Because of
|
|
||||||
their similarity, the helper macros are similar, too: you provide a set of
|
|
||||||
expressions that resolve the union into the actual concrete type.
|
|
||||||
|
|
||||||
## Syntax
|
|
||||||
|
|
||||||
See the documentation for [`graphql_object!`][1] on the general item and type
|
|
||||||
syntax. `graphql_union!` supports only `description` and `interface_resolvers`
|
|
||||||
items, no fields or interfaces can be declared.
|
|
||||||
|
|
||||||
See the documentation for [`graphql_interface!`][2] on the syntax for interface
|
|
||||||
resolvers.
|
|
||||||
|
|
||||||
[1]: macro.graphql_object!.html
|
|
||||||
[2]: macro.graphql_interface!.html
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! graphql_union {
|
|
||||||
|
|
||||||
(
|
|
||||||
@generate,
|
|
||||||
meta = {
|
|
||||||
lifetimes = [$($lifetimes:tt,)*],
|
|
||||||
name = $name:ty,
|
|
||||||
ctx = $ctx:ty,
|
|
||||||
main_self = $main_self:ident,
|
|
||||||
outname = {$($outname:tt)*},
|
|
||||||
scalar = {$($scalar:tt)*},
|
|
||||||
$(description = $desciption:tt,)*
|
|
||||||
additional = {
|
|
||||||
resolver = {
|
|
||||||
$(context = $resolver_ctx: ident,)*
|
|
||||||
items = [
|
|
||||||
$({
|
|
||||||
src = $resolver_src: ty,
|
|
||||||
resolver = $resolver_expr: expr,
|
|
||||||
},)*
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
items = [],
|
|
||||||
) => {
|
|
||||||
$crate::__juniper_impl_trait!(
|
|
||||||
impl<$($scalar)* $(, $lifetimes)* > GraphQLType for $name {
|
|
||||||
type Context = $ctx;
|
|
||||||
type TypeInfo = ();
|
|
||||||
|
|
||||||
fn name(_ : &Self::TypeInfo) -> Option<&str> {
|
|
||||||
Some($($outname)*)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn meta<'r>(
|
|
||||||
info: &Self::TypeInfo,
|
|
||||||
registry: &mut $crate::Registry<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
|
||||||
) -> $crate::meta::MetaType<'r, $crate::__juniper_insert_generic!($($scalar)+)>
|
|
||||||
where for<'__b> &'__b $crate::__juniper_insert_generic!($($scalar)+): $crate::ScalarRefValue<'__b>,
|
|
||||||
$crate::__juniper_insert_generic!($($scalar)+): 'r
|
|
||||||
{
|
|
||||||
let types = &[
|
|
||||||
$(
|
|
||||||
registry.get_type::<$resolver_src>(&()),
|
|
||||||
)*
|
|
||||||
];
|
|
||||||
registry.build_union_type::<$name>(
|
|
||||||
info, types
|
|
||||||
)
|
|
||||||
$(.description($desciption))*
|
|
||||||
.into_meta()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(unused_variables)]
|
|
||||||
fn concrete_type_name(&$main_self, context: &Self::Context, _info: &Self::TypeInfo) -> String {
|
|
||||||
$(let $resolver_ctx = &context;)*
|
|
||||||
|
|
||||||
$(
|
|
||||||
if ($resolver_expr as ::std::option::Option<$resolver_src>).is_some() {
|
|
||||||
return
|
|
||||||
<$resolver_src as $crate::GraphQLType<_>>::name(&()).unwrap().to_owned();
|
|
||||||
}
|
|
||||||
)*
|
|
||||||
|
|
||||||
panic!("Concrete type not handled by instance resolvers on {}", $($outname)*);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn resolve_into_type(
|
|
||||||
&$main_self,
|
|
||||||
_info: &Self::TypeInfo,
|
|
||||||
type_name: &str,
|
|
||||||
_: Option<&[$crate::Selection<$crate::__juniper_insert_generic!($($scalar)*)>]>,
|
|
||||||
executor: &$crate::Executor<Self::Context, $crate::__juniper_insert_generic!($($scalar)*)>,
|
|
||||||
) -> $crate::ExecutionResult<$crate::__juniper_insert_generic!($($scalar)*)> {
|
|
||||||
$(let $resolver_ctx = &executor.context();)*
|
|
||||||
|
|
||||||
$(
|
|
||||||
if type_name == (<$resolver_src as $crate::GraphQLType<_>>::name(&())).unwrap() {
|
|
||||||
return executor.resolve(&(), &$resolver_expr);
|
|
||||||
}
|
|
||||||
)*
|
|
||||||
|
|
||||||
panic!("Concrete type not handled by instance resolvers on {}", $($outname)*);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
(
|
|
||||||
@parse,
|
|
||||||
meta = {$($meta:tt)*},
|
|
||||||
rest = $($rest:tt)*
|
|
||||||
) => {
|
|
||||||
$crate::__juniper_parse_field_list!(
|
|
||||||
success_callback = graphql_union,
|
|
||||||
additional_parser = {
|
|
||||||
callback = __juniper_parse_instance_resolver,
|
|
||||||
header = {},
|
|
||||||
},
|
|
||||||
meta = {$($meta)*},
|
|
||||||
items = [],
|
|
||||||
rest = $($rest)*
|
|
||||||
);
|
|
||||||
};
|
|
||||||
(@$($stuff:tt)*) => {
|
|
||||||
compile_error!("Invalid syntax for `graphql_union!`");
|
|
||||||
};
|
|
||||||
|
|
||||||
($($rest: tt)*) => {
|
|
||||||
$crate::__juniper_parse_object_header!(
|
|
||||||
callback = graphql_union,
|
|
||||||
rest = $($rest)*
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
*/
|
|
|
@ -6,13 +6,12 @@ use crate::{
|
||||||
schema::model::SchemaType,
|
schema::model::SchemaType,
|
||||||
types::scalars::EmptyMutation,
|
types::scalars::EmptyMutation,
|
||||||
validation::test_harness::{MutationRoot, QueryRoot},
|
validation::test_harness::{MutationRoot, QueryRoot},
|
||||||
value::{DefaultScalarValue, ScalarRefValue, ScalarValue},
|
value::{DefaultScalarValue, ScalarValue},
|
||||||
};
|
};
|
||||||
|
|
||||||
fn parse_document<S>(s: &str) -> Document<S>
|
fn parse_document<S>(s: &str) -> Document<S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
parse_document_source(s, &SchemaType::new::<QueryRoot, MutationRoot>(&(), &()))
|
parse_document_source(s, &SchemaType::new::<QueryRoot, MutationRoot>(&(), &()))
|
||||||
.expect(&format!("Parse error on input {:#?}", s))
|
.expect(&format!("Parse error on input {:#?}", s))
|
||||||
|
@ -21,7 +20,6 @@ where
|
||||||
fn parse_document_error<'a, S>(s: &'a str) -> Spanning<ParseError<'a>>
|
fn parse_document_error<'a, S>(s: &'a str) -> Spanning<ParseError<'a>>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
match parse_document_source::<S>(s, &SchemaType::new::<QueryRoot, MutationRoot>(&(), &())) {
|
match parse_document_source::<S>(s, &SchemaType::new::<QueryRoot, MutationRoot>(&(), &())) {
|
||||||
Ok(doc) => panic!("*No* parse error on input {:#?} =>\n{:#?}", s, doc),
|
Ok(doc) => panic!("*No* parse error on input {:#?} =>\n{:#?}", s, doc),
|
||||||
|
|
|
@ -7,7 +7,7 @@ use juniper_codegen::{
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{FromInputValue, InputValue, Type},
|
ast::{FromInputValue, InputValue, Type},
|
||||||
parser::{value::parse_value_literal, Lexer, Parser, SourcePosition, Spanning},
|
parser::{value::parse_value_literal, Lexer, Parser, SourcePosition, Spanning},
|
||||||
value::{DefaultScalarValue, ParseScalarValue, ScalarRefValue, ScalarValue},
|
value::{DefaultScalarValue, ParseScalarValue, ScalarValue},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -72,7 +72,6 @@ where
|
||||||
fn parse_value<S>(s: &str, meta: &MetaType<S>) -> Spanning<InputValue<S>>
|
fn parse_value<S>(s: &str, meta: &MetaType<S>) -> Spanning<InputValue<S>>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'a> &'a S: ScalarRefValue<'a>,
|
|
||||||
{
|
{
|
||||||
let mut lexer = Lexer::new(s);
|
let mut lexer = Lexer::new(s);
|
||||||
let mut parser = Parser::new(&mut lexer).expect(&format!("Lexer error on input {:#?}", s));
|
let mut parser = Parser::new(&mut lexer).expect(&format!("Lexer error on input {:#?}", s));
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
parser::{ParseError, ScalarToken},
|
parser::{ParseError, ScalarToken},
|
||||||
schema::model::SchemaType,
|
schema::model::SchemaType,
|
||||||
types::base::TypeKind,
|
types::base::TypeKind,
|
||||||
value::{DefaultScalarValue, ParseScalarValue, ScalarRefValue, ScalarValue},
|
value::{DefaultScalarValue, ParseScalarValue, ScalarValue},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Whether an item is deprecated, with context.
|
/// Whether an item is deprecated, with context.
|
||||||
|
@ -395,7 +395,6 @@ where
|
||||||
pub fn new<T>(name: Cow<'a, str>) -> Self
|
pub fn new<T>(name: Cow<'a, str>) -> Self
|
||||||
where
|
where
|
||||||
T: FromInputValue<S> + ParseScalarValue<S> + 'a,
|
T: FromInputValue<S> + ParseScalarValue<S> + 'a,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
ScalarMeta {
|
ScalarMeta {
|
||||||
name,
|
name,
|
||||||
|
@ -491,7 +490,6 @@ where
|
||||||
pub fn new<T>(name: Cow<'a, str>, values: &[EnumValue]) -> Self
|
pub fn new<T>(name: Cow<'a, str>, values: &[EnumValue]) -> Self
|
||||||
where
|
where
|
||||||
T: FromInputValue<S>,
|
T: FromInputValue<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
EnumMeta {
|
EnumMeta {
|
||||||
name,
|
name,
|
||||||
|
@ -575,9 +573,7 @@ where
|
||||||
{
|
{
|
||||||
/// Build a new input type with the specified name and input fields
|
/// Build a new input type with the specified name and input fields
|
||||||
pub fn new<T: FromInputValue<S>>(name: Cow<'a, str>, input_fields: &[Argument<'a, S>]) -> Self
|
pub fn new<T: FromInputValue<S>>(name: Cow<'a, str>, input_fields: &[Argument<'a, S>]) -> Self
|
||||||
where
|
where {
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
|
||||||
InputObjectMeta {
|
InputObjectMeta {
|
||||||
name,
|
name,
|
||||||
description: None,
|
description: None,
|
||||||
|
@ -765,7 +761,6 @@ impl<'a, S: fmt::Debug> fmt::Debug for InputObjectMeta<'a, S> {
|
||||||
fn try_parse_fn<S, T>(v: &InputValue<S>) -> bool
|
fn try_parse_fn<S, T>(v: &InputValue<S>) -> bool
|
||||||
where
|
where
|
||||||
T: FromInputValue<S>,
|
T: FromInputValue<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
<T as FromInputValue<S>>::from_input_value(v).is_some()
|
<T as FromInputValue<S>>::from_input_value(v).is_some()
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
executor::{Context, Registry},
|
executor::{Context, Registry},
|
||||||
schema::meta::{Argument, InterfaceMeta, MetaType, ObjectMeta, PlaceholderMeta, UnionMeta},
|
schema::meta::{Argument, InterfaceMeta, MetaType, ObjectMeta, PlaceholderMeta, UnionMeta},
|
||||||
types::{base::GraphQLType, name::Name},
|
types::{base::GraphQLType, name::Name},
|
||||||
value::{DefaultScalarValue, ScalarRefValue, ScalarValue},
|
value::{DefaultScalarValue, ScalarValue},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Root query node of a schema
|
/// Root query node of a schema
|
||||||
|
@ -20,7 +20,6 @@ use crate::{
|
||||||
pub struct RootNode<'a, QueryT: GraphQLType<S>, MutationT: GraphQLType<S>, S = DefaultScalarValue>
|
pub struct RootNode<'a, QueryT: GraphQLType<S>, MutationT: GraphQLType<S>, S = DefaultScalarValue>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub query_type: QueryT,
|
pub query_type: QueryT,
|
||||||
|
@ -80,16 +79,12 @@ where
|
||||||
S: ScalarValue + 'a,
|
S: ScalarValue + 'a,
|
||||||
QueryT: GraphQLType<S, TypeInfo = ()>,
|
QueryT: GraphQLType<S, TypeInfo = ()>,
|
||||||
MutationT: GraphQLType<S, TypeInfo = ()>,
|
MutationT: GraphQLType<S, TypeInfo = ()>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
/// Construct a new root node from query and mutation nodes
|
/// Construct a new root node from query and mutation nodes
|
||||||
///
|
///
|
||||||
/// If the schema should not support mutations, use the
|
/// If the schema should not support mutations, use the
|
||||||
/// `new` constructor instead.
|
/// `new` constructor instead.
|
||||||
pub fn new(query_obj: QueryT, mutation_obj: MutationT) -> Self
|
pub fn new(query_obj: QueryT, mutation_obj: MutationT) -> Self {
|
||||||
where
|
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
|
||||||
RootNode::new_with_info(query_obj, mutation_obj, (), ())
|
RootNode::new_with_info(query_obj, mutation_obj, (), ())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +94,6 @@ where
|
||||||
QueryT: GraphQLType<S>,
|
QueryT: GraphQLType<S>,
|
||||||
MutationT: GraphQLType<S>,
|
MutationT: GraphQLType<S>,
|
||||||
S: ScalarValue + 'a,
|
S: ScalarValue + 'a,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
/// Construct a new root node from query and mutation nodes,
|
/// Construct a new root node from query and mutation nodes,
|
||||||
/// while also providing type info objects for the query and
|
/// while also providing type info objects for the query and
|
||||||
|
@ -109,10 +103,7 @@ where
|
||||||
mutation_obj: MutationT,
|
mutation_obj: MutationT,
|
||||||
query_info: QueryT::TypeInfo,
|
query_info: QueryT::TypeInfo,
|
||||||
mutation_info: MutationT::TypeInfo,
|
mutation_info: MutationT::TypeInfo,
|
||||||
) -> Self
|
) -> Self {
|
||||||
where
|
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
|
||||||
RootNode {
|
RootNode {
|
||||||
query_type: query_obj,
|
query_type: query_obj,
|
||||||
mutation_type: mutation_obj,
|
mutation_type: mutation_obj,
|
||||||
|
@ -132,7 +123,6 @@ impl<'a, S> SchemaType<'a, S> {
|
||||||
S: ScalarValue + 'a,
|
S: ScalarValue + 'a,
|
||||||
QueryT: GraphQLType<S>,
|
QueryT: GraphQLType<S>,
|
||||||
MutationT: GraphQLType<S>,
|
MutationT: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let mut directives = FnvHashMap::default();
|
let mut directives = FnvHashMap::default();
|
||||||
let query_type_name: String;
|
let query_type_name: String;
|
||||||
|
@ -425,7 +415,6 @@ where
|
||||||
fn new_skip(registry: &mut Registry<'a, S>) -> DirectiveType<'a, S>
|
fn new_skip(registry: &mut Registry<'a, S>) -> DirectiveType<'a, S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
Self::new(
|
Self::new(
|
||||||
"skip",
|
"skip",
|
||||||
|
@ -441,7 +430,6 @@ where
|
||||||
fn new_include(registry: &mut Registry<'a, S>) -> DirectiveType<'a, S>
|
fn new_include(registry: &mut Registry<'a, S>) -> DirectiveType<'a, S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
Self::new(
|
Self::new(
|
||||||
"include",
|
"include",
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::{
|
||||||
ast::Selection,
|
ast::Selection,
|
||||||
executor::{ExecutionResult, Executor, Registry},
|
executor::{ExecutionResult, Executor, Registry},
|
||||||
types::base::{Arguments, GraphQLType, TypeKind},
|
types::base::{Arguments, GraphQLType, TypeKind},
|
||||||
value::{ScalarRefValue, ScalarValue, Value},
|
value::{ScalarValue, Value},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::schema::{
|
use crate::schema::{
|
||||||
|
@ -18,7 +18,6 @@ where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
QueryT: GraphQLType<S, Context = CtxT>,
|
QueryT: GraphQLType<S, Context = CtxT>,
|
||||||
MutationT: GraphQLType<S, Context = CtxT>,
|
MutationT: GraphQLType<S, Context = CtxT>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = CtxT;
|
type Context = CtxT;
|
||||||
type TypeInfo = QueryT::TypeInfo;
|
type TypeInfo = QueryT::TypeInfo;
|
||||||
|
@ -30,7 +29,6 @@ where
|
||||||
fn meta<'r>(info: &QueryT::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
fn meta<'r>(info: &QueryT::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
||||||
where
|
where
|
||||||
S: 'r,
|
S: 'r,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
QueryT::meta(info, registry)
|
QueryT::meta(info, registry)
|
||||||
}
|
}
|
||||||
|
@ -86,7 +84,6 @@ where
|
||||||
MutationT: crate::GraphQLTypeAsync<S, Context = CtxT>,
|
MutationT: crate::GraphQLTypeAsync<S, Context = CtxT>,
|
||||||
MutationT::TypeInfo: Send + Sync,
|
MutationT::TypeInfo: Send + Sync,
|
||||||
CtxT: Send + Sync,
|
CtxT: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn resolve_field_async<'b>(
|
fn resolve_field_async<'b>(
|
||||||
&'b self,
|
&'b self,
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
base::{Arguments, GraphQLType},
|
base::{Arguments, GraphQLType},
|
||||||
scalars::EmptyMutation,
|
scalars::EmptyMutation,
|
||||||
},
|
},
|
||||||
value::{ScalarRefValue, ScalarValue, Value},
|
value::{ScalarValue, Value},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct NodeTypeInfo {
|
pub struct NodeTypeInfo {
|
||||||
|
@ -22,7 +22,6 @@ pub struct Node {
|
||||||
impl<S> GraphQLType<S> for Node
|
impl<S> GraphQLType<S> for Node
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = NodeTypeInfo;
|
type TypeInfo = NodeTypeInfo;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{Directive, FromInputValue, InputValue, Selection},
|
ast::{Directive, FromInputValue, InputValue, Selection},
|
||||||
value::{Object, ScalarRefValue, ScalarValue, Value},
|
value::{Object, ScalarValue, Value},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -17,7 +17,6 @@ where
|
||||||
Self::Context: Send + Sync,
|
Self::Context: Send + Sync,
|
||||||
Self::TypeInfo: Send + Sync,
|
Self::TypeInfo: Send + Sync,
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn resolve_field_async<'a>(
|
fn resolve_field_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
@ -75,7 +74,6 @@ where
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
CtxT: Send + Sync,
|
CtxT: Send + Sync,
|
||||||
'e: 'a,
|
'e: 'a,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
Box::pin(resolve_selection_set_into_async_recursive(
|
Box::pin(resolve_selection_set_into_async_recursive(
|
||||||
instance,
|
instance,
|
||||||
|
@ -107,7 +105,6 @@ where
|
||||||
T::TypeInfo: Send + Sync,
|
T::TypeInfo: Send + Sync,
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
CtxT: Send + Sync,
|
CtxT: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
use futures::stream::{FuturesOrdered, StreamExt};
|
use futures::stream::{FuturesOrdered, StreamExt};
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use juniper_codegen::GraphQLEnumInternal as GraphQLEnum;
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{Directive, FromInputValue, InputValue, Selection},
|
ast::{Directive, FromInputValue, InputValue, Selection},
|
||||||
executor::Variables,
|
executor::Variables,
|
||||||
value::{DefaultScalarValue, Object, ScalarRefValue, ScalarValue, Value},
|
value::{DefaultScalarValue, Object, ScalarValue, Value},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -116,7 +116,6 @@ where
|
||||||
pub fn get<T>(&self, key: &str) -> Option<T>
|
pub fn get<T>(&self, key: &str) -> Option<T>
|
||||||
where
|
where
|
||||||
T: FromInputValue<S>,
|
T: FromInputValue<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
match self.args {
|
match self.args {
|
||||||
Some(ref args) => match args.get(key) {
|
Some(ref args) => match args.get(key) {
|
||||||
|
@ -238,7 +237,6 @@ impl GraphQLType for User
|
||||||
pub trait GraphQLType<S = DefaultScalarValue>: Sized
|
pub trait GraphQLType<S = DefaultScalarValue>: Sized
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
/// The expected context type for this GraphQL type
|
/// The expected context type for this GraphQL type
|
||||||
///
|
///
|
||||||
|
@ -353,7 +351,6 @@ pub(crate) fn resolve_selection_set_into<T, CtxT, S>(
|
||||||
where
|
where
|
||||||
T: GraphQLType<S, Context = CtxT>,
|
T: GraphQLType<S, Context = CtxT>,
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let meta_type = executor
|
let meta_type = executor
|
||||||
.schema()
|
.schema()
|
||||||
|
@ -505,7 +502,6 @@ pub(super) fn is_excluded<S>(
|
||||||
) -> bool
|
) -> bool
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
if let Some(ref directives) = *directives {
|
if let Some(ref directives) = *directives {
|
||||||
for &Spanning {
|
for &Spanning {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{FromInputValue, InputValue, Selection, ToInputValue},
|
ast::{FromInputValue, InputValue, Selection, ToInputValue},
|
||||||
schema::meta::MetaType,
|
schema::meta::MetaType,
|
||||||
value::{ScalarRefValue, ScalarValue, Value},
|
value::{ScalarValue, Value},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -13,7 +13,6 @@ impl<S, T, CtxT> GraphQLType<S> for Option<T>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: GraphQLType<S, Context = CtxT>,
|
T: GraphQLType<S, Context = CtxT>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = CtxT;
|
type Context = CtxT;
|
||||||
type TypeInfo = T::TypeInfo;
|
type TypeInfo = T::TypeInfo;
|
||||||
|
@ -25,7 +24,6 @@ where
|
||||||
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
||||||
where
|
where
|
||||||
S: 'r,
|
S: 'r,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
registry.build_nullable_type::<T>(info).into_meta()
|
registry.build_nullable_type::<T>(info).into_meta()
|
||||||
}
|
}
|
||||||
|
@ -48,10 +46,7 @@ where
|
||||||
T: FromInputValue<S>,
|
T: FromInputValue<S>,
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
{
|
{
|
||||||
fn from_input_value<'a>(v: &'a InputValue<S>) -> Option<Option<T>>
|
fn from_input_value<'a>(v: &'a InputValue<S>) -> Option<Option<T>> {
|
||||||
where
|
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
|
||||||
match v {
|
match v {
|
||||||
&InputValue::Null => Some(None),
|
&InputValue::Null => Some(None),
|
||||||
v => match v.convert() {
|
v => match v.convert() {
|
||||||
|
@ -79,7 +74,6 @@ impl<S, T, CtxT> GraphQLType<S> for Vec<T>
|
||||||
where
|
where
|
||||||
T: GraphQLType<S, Context = CtxT>,
|
T: GraphQLType<S, Context = CtxT>,
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = CtxT;
|
type Context = CtxT;
|
||||||
type TypeInfo = T::TypeInfo;
|
type TypeInfo = T::TypeInfo;
|
||||||
|
@ -91,7 +85,6 @@ where
|
||||||
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
||||||
where
|
where
|
||||||
S: 'r,
|
S: 'r,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
registry.build_list_type::<T>(info).into_meta()
|
registry.build_list_type::<T>(info).into_meta()
|
||||||
}
|
}
|
||||||
|
@ -112,9 +105,7 @@ where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
{
|
{
|
||||||
fn from_input_value<'a>(v: &'a InputValue<S>) -> Option<Vec<T>>
|
fn from_input_value<'a>(v: &'a InputValue<S>) -> Option<Vec<T>>
|
||||||
where
|
where {
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
|
||||||
match *v {
|
match *v {
|
||||||
InputValue::List(ref ls) => {
|
InputValue::List(ref ls) => {
|
||||||
let v: Vec<_> = ls.iter().filter_map(|i| i.item.convert()).collect();
|
let v: Vec<_> = ls.iter().filter_map(|i| i.item.convert()).collect();
|
||||||
|
@ -150,7 +141,6 @@ impl<'a, S, T, CtxT> GraphQLType<S> for &'a [T]
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: GraphQLType<S, Context = CtxT>,
|
T: GraphQLType<S, Context = CtxT>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = CtxT;
|
type Context = CtxT;
|
||||||
type TypeInfo = T::TypeInfo;
|
type TypeInfo = T::TypeInfo;
|
||||||
|
@ -162,7 +152,6 @@ where
|
||||||
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
||||||
where
|
where
|
||||||
S: 'r,
|
S: 'r,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
registry.build_list_type::<T>(info).into_meta()
|
registry.build_list_type::<T>(info).into_meta()
|
||||||
}
|
}
|
||||||
|
@ -196,7 +185,6 @@ where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
I: Iterator<Item = T> + ExactSizeIterator,
|
I: Iterator<Item = T> + ExactSizeIterator,
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let stop_on_null = executor
|
let stop_on_null = executor
|
||||||
.current_type()
|
.current_type()
|
||||||
|
@ -230,7 +218,6 @@ where
|
||||||
T: crate::GraphQLTypeAsync<S>,
|
T: crate::GraphQLTypeAsync<S>,
|
||||||
T::TypeInfo: Send + Sync,
|
T::TypeInfo: Send + Sync,
|
||||||
T::Context: Send + Sync,
|
T::Context: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
use futures::stream::{FuturesOrdered, StreamExt};
|
use futures::stream::{FuturesOrdered, StreamExt};
|
||||||
use std::iter::FromIterator;
|
use std::iter::FromIterator;
|
||||||
|
@ -263,7 +250,6 @@ where
|
||||||
T::TypeInfo: Send + Sync,
|
T::TypeInfo: Send + Sync,
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
CtxT: Send + Sync,
|
CtxT: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn resolve_async<'a>(
|
fn resolve_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
@ -283,7 +269,6 @@ where
|
||||||
T::TypeInfo: Send + Sync,
|
T::TypeInfo: Send + Sync,
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
CtxT: Send + Sync,
|
CtxT: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn resolve_async<'a>(
|
fn resolve_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
@ -303,7 +288,6 @@ where
|
||||||
T::TypeInfo: Send + Sync,
|
T::TypeInfo: Send + Sync,
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
CtxT: Send + Sync,
|
CtxT: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn resolve_async<'a>(
|
fn resolve_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
|
|
@ -5,14 +5,13 @@ use crate::{
|
||||||
executor::{ExecutionResult, Executor, Registry},
|
executor::{ExecutionResult, Executor, Registry},
|
||||||
schema::meta::MetaType,
|
schema::meta::MetaType,
|
||||||
types::base::{Arguments, GraphQLType},
|
types::base::{Arguments, GraphQLType},
|
||||||
value::{ScalarRefValue, ScalarValue, Value},
|
value::{ScalarValue, Value},
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<S, T, CtxT> GraphQLType<S> for Box<T>
|
impl<S, T, CtxT> GraphQLType<S> for Box<T>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: GraphQLType<S, Context = CtxT>,
|
T: GraphQLType<S, Context = CtxT>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = CtxT;
|
type Context = CtxT;
|
||||||
type TypeInfo = T::TypeInfo;
|
type TypeInfo = T::TypeInfo;
|
||||||
|
@ -24,7 +23,6 @@ where
|
||||||
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
||||||
where
|
where
|
||||||
S: 'r,
|
S: 'r,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
T::meta(info, registry)
|
T::meta(info, registry)
|
||||||
}
|
}
|
||||||
|
@ -64,10 +62,7 @@ where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: FromInputValue<S>,
|
T: FromInputValue<S>,
|
||||||
{
|
{
|
||||||
fn from_input_value<'a>(v: &'a InputValue<S>) -> Option<Box<T>>
|
fn from_input_value<'a>(v: &'a InputValue<S>) -> Option<Box<T>> {
|
||||||
where
|
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
|
||||||
match <T as FromInputValue<S>>::from_input_value(v) {
|
match <T as FromInputValue<S>>::from_input_value(v) {
|
||||||
Some(v) => Some(Box::new(v)),
|
Some(v) => Some(Box::new(v)),
|
||||||
None => None,
|
None => None,
|
||||||
|
@ -89,7 +84,6 @@ impl<'e, S, T, CtxT> GraphQLType<S> for &'e T
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: GraphQLType<S, Context = CtxT>,
|
T: GraphQLType<S, Context = CtxT>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = CtxT;
|
type Context = CtxT;
|
||||||
type TypeInfo = T::TypeInfo;
|
type TypeInfo = T::TypeInfo;
|
||||||
|
@ -101,7 +95,6 @@ where
|
||||||
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
||||||
where
|
where
|
||||||
S: 'r,
|
S: 'r,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
T::meta(info, registry)
|
T::meta(info, registry)
|
||||||
}
|
}
|
||||||
|
@ -143,7 +136,6 @@ where
|
||||||
T: crate::GraphQLTypeAsync<S>,
|
T: crate::GraphQLTypeAsync<S>,
|
||||||
T::TypeInfo: Send + Sync,
|
T::TypeInfo: Send + Sync,
|
||||||
T::Context: Send + Sync,
|
T::Context: Send + Sync,
|
||||||
for<'c> &'c S: ScalarRefValue<'c>,
|
|
||||||
{
|
{
|
||||||
fn resolve_field_async<'b>(
|
fn resolve_field_async<'b>(
|
||||||
&'b self,
|
&'b self,
|
||||||
|
@ -179,7 +171,6 @@ impl<S, T> GraphQLType<S> for Arc<T>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
T: GraphQLType<S>,
|
T: GraphQLType<S>,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = T::Context;
|
type Context = T::Context;
|
||||||
type TypeInfo = T::TypeInfo;
|
type TypeInfo = T::TypeInfo;
|
||||||
|
@ -191,7 +182,6 @@ where
|
||||||
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
fn meta<'r>(info: &T::TypeInfo, registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
||||||
where
|
where
|
||||||
S: 'r,
|
S: 'r,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
T::meta(info, registry)
|
T::meta(info, registry)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
parser::{LexerError, ParseError, ScalarToken, Token},
|
parser::{LexerError, ParseError, ScalarToken, Token},
|
||||||
schema::meta::MetaType,
|
schema::meta::MetaType,
|
||||||
types::base::GraphQLType,
|
types::base::GraphQLType,
|
||||||
value::{ParseScalarResult, ScalarRefValue, ScalarValue, Value},
|
value::{ParseScalarResult, ScalarValue, Value},
|
||||||
};
|
};
|
||||||
|
|
||||||
/// An ID as defined by the GraphQL specification
|
/// An ID as defined by the GraphQL specification
|
||||||
|
@ -169,7 +169,6 @@ where
|
||||||
impl<'a, S> GraphQLType<S> for &'a str
|
impl<'a, S> GraphQLType<S> for &'a str
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -181,7 +180,6 @@ where
|
||||||
fn meta<'r>(_: &(), registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
fn meta<'r>(_: &(), registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
||||||
where
|
where
|
||||||
S: 'r,
|
S: 'r,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
registry.build_scalar_type::<String>(&()).into_meta()
|
registry.build_scalar_type::<String>(&()).into_meta()
|
||||||
}
|
}
|
||||||
|
@ -200,7 +198,6 @@ where
|
||||||
impl<'e, S> crate::GraphQLTypeAsync<S> for &'e str
|
impl<'e, S> crate::GraphQLTypeAsync<S> for &'e str
|
||||||
where
|
where
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn resolve_async<'a>(
|
fn resolve_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
@ -314,7 +311,6 @@ unsafe impl<T> Send for EmptyMutation<T> {}
|
||||||
impl<S, T> GraphQLType<S> for EmptyMutation<T>
|
impl<S, T> GraphQLType<S> for EmptyMutation<T>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = T;
|
type Context = T;
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -326,7 +322,6 @@ where
|
||||||
fn meta<'r>(_: &(), registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
fn meta<'r>(_: &(), registry: &mut Registry<'r, S>) -> MetaType<'r, S>
|
||||||
where
|
where
|
||||||
S: 'r,
|
S: 'r,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
registry.build_object_type::<Self>(&(), &[]).into_meta()
|
registry.build_object_type::<Self>(&(), &[]).into_meta()
|
||||||
}
|
}
|
||||||
|
@ -340,7 +335,6 @@ where
|
||||||
Self::TypeInfo: Send + Sync,
|
Self::TypeInfo: Send + Sync,
|
||||||
Self::Context: Send + Sync,
|
Self::Context: Send + Sync,
|
||||||
T: Send + Sync,
|
T: Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
model::{SchemaType, TypeType},
|
model::{SchemaType, TypeType},
|
||||||
},
|
},
|
||||||
validation::RuleError,
|
validation::RuleError,
|
||||||
value::{ScalarRefValue, ScalarValue},
|
value::ScalarValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -26,7 +26,6 @@ pub fn validate_input_values<S>(
|
||||||
) -> Vec<RuleError>
|
) -> Vec<RuleError>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let mut errs = vec![];
|
let mut errs = vec![];
|
||||||
|
|
||||||
|
@ -49,7 +48,6 @@ fn validate_var_defs<S>(
|
||||||
errors: &mut Vec<RuleError>,
|
errors: &mut Vec<RuleError>,
|
||||||
) where
|
) where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
for &(ref name, ref def) in var_defs.iter() {
|
for &(ref name, ref def) in var_defs.iter() {
|
||||||
let raw_type_name = def.var_type.item.innermost_name();
|
let raw_type_name = def.var_type.item.innermost_name();
|
||||||
|
@ -91,7 +89,6 @@ fn unify_value<'a, S>(
|
||||||
) -> Vec<RuleError>
|
) -> Vec<RuleError>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let mut errors: Vec<RuleError> = vec![];
|
let mut errors: Vec<RuleError> = vec![];
|
||||||
|
|
||||||
|
@ -222,12 +219,13 @@ fn unify_enum<'a, S>(
|
||||||
) -> Vec<RuleError>
|
) -> Vec<RuleError>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let mut errors: Vec<RuleError> = vec![];
|
let mut errors: Vec<RuleError> = vec![];
|
||||||
|
|
||||||
match *value {
|
match *value {
|
||||||
InputValue::Scalar(ref scalar) if scalar.is_type::<String>() => {
|
// TODO: avoid this bad duplicate as_str() call. (value system refactor)
|
||||||
if let Some(ref name) = <&S as Into<Option<&String>>>::into(scalar) {
|
InputValue::Scalar(ref scalar) if scalar.as_str().is_some() => {
|
||||||
|
if let Some(ref name) = scalar.as_str() {
|
||||||
if !meta.values.iter().any(|ev| &ev.name == *name) {
|
if !meta.values.iter().any(|ev| &ev.name == *name) {
|
||||||
errors.push(unification_error(
|
errors.push(unification_error(
|
||||||
var_name,
|
var_name,
|
||||||
|
@ -268,7 +266,6 @@ fn unify_input_object<'a, S>(
|
||||||
) -> Vec<RuleError>
|
) -> Vec<RuleError>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
let mut errors: Vec<RuleError> = vec![];
|
let mut errors: Vec<RuleError> = vec![];
|
||||||
|
|
||||||
|
|
|
@ -752,7 +752,7 @@ mod tests {
|
||||||
expect_fails_rule, expect_fails_rule_with_schema, expect_passes_rule,
|
expect_fails_rule, expect_fails_rule_with_schema, expect_passes_rule,
|
||||||
expect_passes_rule_with_schema, RuleError,
|
expect_passes_rule_with_schema, RuleError,
|
||||||
},
|
},
|
||||||
value::{DefaultScalarValue, ScalarRefValue, ScalarValue},
|
value::{DefaultScalarValue, ScalarValue},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1379,7 +1379,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for SomeBox
|
impl<S> GraphQLType<S> for SomeBox
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -1405,7 +1404,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for StringBox
|
impl<S> GraphQLType<S> for StringBox
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -1437,7 +1435,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for IntBox
|
impl<S> GraphQLType<S> for IntBox
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -1469,7 +1466,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for NonNullStringBox1
|
impl<S> GraphQLType<S> for NonNullStringBox1
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -1491,7 +1487,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for NonNullStringBox1Impl
|
impl<S> GraphQLType<S> for NonNullStringBox1Impl
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -1523,7 +1518,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for NonNullStringBox2
|
impl<S> GraphQLType<S> for NonNullStringBox2
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -1545,7 +1539,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for NonNullStringBox2Impl
|
impl<S> GraphQLType<S> for NonNullStringBox2Impl
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -1577,7 +1570,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for Node
|
impl<S> GraphQLType<S> for Node
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -1602,7 +1594,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for Edge
|
impl<S> GraphQLType<S> for Edge
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -1624,7 +1615,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for Connection
|
impl<S> GraphQLType<S> for Connection
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -1646,7 +1636,6 @@ mod tests {
|
||||||
impl<S> GraphQLType<S> for QueryRoot
|
impl<S> GraphQLType<S> for QueryRoot
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
types::{base::GraphQLType, scalars::ID},
|
types::{base::GraphQLType, scalars::ID},
|
||||||
validation::{visit, MultiVisitorNil, RuleError, ValidatorContext, Visitor},
|
validation::{visit, MultiVisitorNil, RuleError, ValidatorContext, Visitor},
|
||||||
value::{ScalarRefValue, ScalarValue},
|
value::ScalarValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Being;
|
struct Being;
|
||||||
|
@ -68,7 +68,6 @@ struct ComplexInput {
|
||||||
impl<S> GraphQLType<S> for Being
|
impl<S> GraphQLType<S> for Being
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -92,7 +91,6 @@ where
|
||||||
impl<S> GraphQLType<S> for Pet
|
impl<S> GraphQLType<S> for Pet
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -116,7 +114,6 @@ where
|
||||||
impl<S> GraphQLType<S> for Canine
|
impl<S> GraphQLType<S> for Canine
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -140,7 +137,6 @@ where
|
||||||
impl<S> GraphQLType<S> for DogCommand
|
impl<S> GraphQLType<S> for DogCommand
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -170,10 +166,7 @@ impl<S> FromInputValue<S> for DogCommand
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
{
|
{
|
||||||
fn from_input_value<'a>(v: &InputValue<S>) -> Option<DogCommand>
|
fn from_input_value<'a>(v: &InputValue<S>) -> Option<DogCommand> {
|
||||||
where
|
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
|
||||||
match v.as_enum_value() {
|
match v.as_enum_value() {
|
||||||
Some("SIT") => Some(DogCommand::Sit),
|
Some("SIT") => Some(DogCommand::Sit),
|
||||||
Some("HEEL") => Some(DogCommand::Heel),
|
Some("HEEL") => Some(DogCommand::Heel),
|
||||||
|
@ -186,7 +179,6 @@ where
|
||||||
impl<S> GraphQLType<S> for Dog
|
impl<S> GraphQLType<S> for Dog
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -232,7 +224,6 @@ where
|
||||||
impl<S> GraphQLType<S> for FurColor
|
impl<S> GraphQLType<S> for FurColor
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -263,12 +254,7 @@ impl<S> FromInputValue<S> for FurColor
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
{
|
{
|
||||||
fn from_input_value<'a>(v: &InputValue<S>) -> Option<FurColor>
|
fn from_input_value<'a>(v: &InputValue<S>) -> Option<FurColor> {
|
||||||
where
|
|
||||||
// S: 'a,
|
|
||||||
// &'a S: ScalarRefValue<'a>,
|
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
|
||||||
match v.as_enum_value() {
|
match v.as_enum_value() {
|
||||||
Some("BROWN") => Some(FurColor::Brown),
|
Some("BROWN") => Some(FurColor::Brown),
|
||||||
Some("BLACK") => Some(FurColor::Black),
|
Some("BLACK") => Some(FurColor::Black),
|
||||||
|
@ -282,7 +268,6 @@ where
|
||||||
impl<S> GraphQLType<S> for Cat
|
impl<S> GraphQLType<S> for Cat
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -315,7 +300,6 @@ where
|
||||||
impl<S> GraphQLType<S> for CatOrDog
|
impl<S> GraphQLType<S> for CatOrDog
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -337,7 +321,6 @@ where
|
||||||
impl<S> GraphQLType<S> for Intelligent
|
impl<S> GraphQLType<S> for Intelligent
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -359,7 +342,6 @@ where
|
||||||
impl<S> GraphQLType<S> for Human
|
impl<S> GraphQLType<S> for Human
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -393,7 +375,6 @@ where
|
||||||
impl<S> GraphQLType<S> for Alien
|
impl<S> GraphQLType<S> for Alien
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -427,7 +408,6 @@ where
|
||||||
impl<S> GraphQLType<S> for DogOrHuman
|
impl<S> GraphQLType<S> for DogOrHuman
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -449,7 +429,6 @@ where
|
||||||
impl<S> GraphQLType<S> for HumanOrAlien
|
impl<S> GraphQLType<S> for HumanOrAlien
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -471,7 +450,6 @@ where
|
||||||
impl<S> GraphQLType<S> for ComplexInput
|
impl<S> GraphQLType<S> for ComplexInput
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -502,11 +480,7 @@ impl<S> FromInputValue<S> for ComplexInput
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
{
|
{
|
||||||
fn from_input_value<'a>(v: &InputValue<S>) -> Option<ComplexInput>
|
fn from_input_value<'a>(v: &InputValue<S>) -> Option<ComplexInput> {
|
||||||
where
|
|
||||||
for<'b> &'b S: ScalarRefValue<'b>, // S: 'a,
|
|
||||||
// &'a S: ScalarRefValue<'a>
|
|
||||||
{
|
|
||||||
let obj = match v.to_object_value() {
|
let obj = match v.to_object_value() {
|
||||||
Some(o) => o,
|
Some(o) => o,
|
||||||
None => return None,
|
None => return None,
|
||||||
|
@ -528,7 +502,6 @@ where
|
||||||
impl<S> GraphQLType<S> for ComplicatedArgs
|
impl<S> GraphQLType<S> for ComplicatedArgs
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -592,7 +565,6 @@ where
|
||||||
impl<S> GraphQLType<S> for QueryRoot
|
impl<S> GraphQLType<S> for QueryRoot
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -626,7 +598,6 @@ where
|
||||||
impl<S> GraphQLType<S> for MutationRoot
|
impl<S> GraphQLType<S> for MutationRoot
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -656,7 +627,6 @@ where
|
||||||
|
|
||||||
pub fn validate<'a, Q, M, V, F, S>(r: Q, m: M, q: &'a str, factory: F) -> Vec<RuleError>
|
pub fn validate<'a, Q, M, V, F, S>(r: Q, m: M, q: &'a str, factory: F) -> Vec<RuleError>
|
||||||
where
|
where
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
S: ScalarValue + 'a,
|
S: ScalarValue + 'a,
|
||||||
Q: GraphQLType<S, TypeInfo = ()>,
|
Q: GraphQLType<S, TypeInfo = ()>,
|
||||||
M: GraphQLType<S, TypeInfo = ()>,
|
M: GraphQLType<S, TypeInfo = ()>,
|
||||||
|
@ -709,7 +679,6 @@ where
|
||||||
pub fn expect_passes_rule<'a, V, F, S>(factory: F, q: &'a str)
|
pub fn expect_passes_rule<'a, V, F, S>(factory: F, q: &'a str)
|
||||||
where
|
where
|
||||||
S: ScalarValue + 'a,
|
S: ScalarValue + 'a,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
V: Visitor<'a, S> + 'a,
|
V: Visitor<'a, S> + 'a,
|
||||||
F: Fn() -> V,
|
F: Fn() -> V,
|
||||||
{
|
{
|
||||||
|
@ -719,7 +688,6 @@ where
|
||||||
pub fn expect_passes_rule_with_schema<'a, Q, M, V, F, S>(r: Q, m: M, factory: F, q: &'a str)
|
pub fn expect_passes_rule_with_schema<'a, Q, M, V, F, S>(r: Q, m: M, factory: F, q: &'a str)
|
||||||
where
|
where
|
||||||
S: ScalarValue + 'a,
|
S: ScalarValue + 'a,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
Q: GraphQLType<S, TypeInfo = ()>,
|
Q: GraphQLType<S, TypeInfo = ()>,
|
||||||
M: GraphQLType<S, TypeInfo = ()>,
|
M: GraphQLType<S, TypeInfo = ()>,
|
||||||
V: Visitor<'a, S> + 'a,
|
V: Visitor<'a, S> + 'a,
|
||||||
|
@ -736,7 +704,6 @@ where
|
||||||
pub fn expect_fails_rule<'a, V, F, S>(factory: F, q: &'a str, expected_errors: &[RuleError])
|
pub fn expect_fails_rule<'a, V, F, S>(factory: F, q: &'a str, expected_errors: &[RuleError])
|
||||||
where
|
where
|
||||||
S: ScalarValue + 'a,
|
S: ScalarValue + 'a,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
V: Visitor<'a, S> + 'a,
|
V: Visitor<'a, S> + 'a,
|
||||||
F: Fn() -> V,
|
F: Fn() -> V,
|
||||||
{
|
{
|
||||||
|
@ -751,7 +718,6 @@ pub fn expect_fails_rule_with_schema<'a, Q, M, V, F, S>(
|
||||||
expected_errors: &[RuleError],
|
expected_errors: &[RuleError],
|
||||||
) where
|
) where
|
||||||
S: ScalarValue + 'a,
|
S: ScalarValue + 'a,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
Q: GraphQLType<S, TypeInfo = ()>,
|
Q: GraphQLType<S, TypeInfo = ()>,
|
||||||
M: GraphQLType<S, TypeInfo = ()>,
|
M: GraphQLType<S, TypeInfo = ()>,
|
||||||
V: Visitor<'a, S> + 'a,
|
V: Visitor<'a, S> + 'a,
|
||||||
|
|
|
@ -7,9 +7,7 @@ mod scalar;
|
||||||
|
|
||||||
pub use self::object::Object;
|
pub use self::object::Object;
|
||||||
|
|
||||||
pub use self::scalar::{
|
pub use self::scalar::{DefaultScalarValue, ParseScalarResult, ParseScalarValue, ScalarValue};
|
||||||
DefaultScalarValue, ParseScalarResult, ParseScalarValue, ScalarRefValue, ScalarValue,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Serializable value returned from query and field execution.
|
/// Serializable value returned from query and field execution.
|
||||||
///
|
///
|
||||||
|
@ -104,12 +102,12 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// View the underlying float value, if present.
|
/// View the underlying float value, if present.
|
||||||
#[deprecated(since = "0.11.0", note = "Use `Value::as_scalar_value` instead")]
|
|
||||||
pub fn as_float_value(&self) -> Option<f64>
|
pub fn as_float_value(&self) -> Option<f64>
|
||||||
where
|
where {
|
||||||
for<'a> &'a S: ScalarRefValue<'a>,
|
match self {
|
||||||
{
|
Value::Scalar(ref s) => s.as_float(),
|
||||||
self.as_scalar_value::<f64>().cloned()
|
_ => None,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// View the underlying object value, if present.
|
/// View the underlying object value, if present.
|
||||||
|
@ -155,7 +153,6 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// View the underlying string value, if present.
|
/// View the underlying string value, if present.
|
||||||
#[deprecated(since = "0.11.0", note = "Use `Value::as_scalar_value` instead")]
|
|
||||||
pub fn as_string_value<'a>(&'a self) -> Option<&'a str>
|
pub fn as_string_value<'a>(&'a self) -> Option<&'a str>
|
||||||
where
|
where
|
||||||
Option<&'a String>: From<&'a S>,
|
Option<&'a String>: From<&'a S>,
|
||||||
|
|
|
@ -63,6 +63,13 @@ pub trait ParseScalarValue<S = DefaultScalarValue> {
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
|
/// fn as_str(&self) -> Option<&str> {
|
||||||
|
/// match *self {
|
||||||
|
/// MyScalarValue::String(ref s) => Some(s.as_str()),
|
||||||
|
/// _ => None,
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
///
|
||||||
/// fn as_float(&self) -> Option<f64> {
|
/// fn as_float(&self) -> Option<f64> {
|
||||||
/// match *self {
|
/// match *self {
|
||||||
/// MyScalarValue::Int(ref i) => Some(*i as f64),
|
/// MyScalarValue::Int(ref i) => Some(*i as f64),
|
||||||
|
@ -157,19 +164,7 @@ pub trait ParseScalarValue<S = DefaultScalarValue> {
|
||||||
/// # fn main() {}
|
/// # fn main() {}
|
||||||
/// ```
|
/// ```
|
||||||
pub trait ScalarValue:
|
pub trait ScalarValue:
|
||||||
Debug
|
Debug + Display + PartialEq + Clone + Serialize + From<String> + From<bool> + From<i32> + From<f64>
|
||||||
+ Display
|
|
||||||
+ PartialEq
|
|
||||||
+ Clone
|
|
||||||
+ Serialize
|
|
||||||
+ From<String>
|
|
||||||
+ From<bool>
|
|
||||||
+ From<i32>
|
|
||||||
+ From<f64>
|
|
||||||
+ Into<Option<bool>>
|
|
||||||
+ Into<Option<i32>>
|
|
||||||
+ Into<Option<f64>>
|
|
||||||
+ Into<Option<String>>
|
|
||||||
{
|
{
|
||||||
/// Serde visitor used to deserialize this scalar value
|
/// Serde visitor used to deserialize this scalar value
|
||||||
type Visitor: for<'de> de::Visitor<'de, Value = Self> + Default;
|
type Visitor: for<'de> de::Visitor<'de, Value = Self> + Default;
|
||||||
|
@ -206,6 +201,12 @@ pub trait ScalarValue:
|
||||||
/// scalar values
|
/// scalar values
|
||||||
fn as_string(&self) -> Option<String>;
|
fn as_string(&self) -> Option<String>;
|
||||||
|
|
||||||
|
/// Convert the given scalar value into a string value
|
||||||
|
///
|
||||||
|
/// This function is used for implementing `GraphQLType` for `String` for all
|
||||||
|
/// scalar values
|
||||||
|
fn as_str(&self) -> Option<&str>;
|
||||||
|
|
||||||
/// Convert the given scalar value into a float value
|
/// Convert the given scalar value into a float value
|
||||||
///
|
///
|
||||||
/// This function is used for implementing `GraphQLType` for `f64` for all
|
/// This function is used for implementing `GraphQLType` for `f64` for all
|
||||||
|
@ -221,33 +222,6 @@ pub trait ScalarValue:
|
||||||
fn as_boolean(&self) -> Option<bool>;
|
fn as_boolean(&self) -> Option<bool>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A marker trait extending the [`ScalarValue`](../trait.ScalarValue.html) trait
|
|
||||||
///
|
|
||||||
/// This trait should not be relied on directly by most apps. However, you may
|
|
||||||
/// need a where clause in the form of `for<'b> &'b S: ScalarRefValue<'b>` to
|
|
||||||
/// abstract over different scalar value types.
|
|
||||||
///
|
|
||||||
/// This is automatically implemented for a type as soon as the type implements
|
|
||||||
/// `ScalarValue` and the additional conversations.
|
|
||||||
pub trait ScalarRefValue<'a>:
|
|
||||||
Debug
|
|
||||||
+ Into<Option<&'a bool>>
|
|
||||||
+ Into<Option<&'a i32>>
|
|
||||||
+ Into<Option<&'a String>>
|
|
||||||
+ Into<Option<&'a f64>>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T> ScalarRefValue<'a> for &'a T
|
|
||||||
where
|
|
||||||
T: ScalarValue,
|
|
||||||
&'a T: Into<Option<&'a bool>>
|
|
||||||
+ Into<Option<&'a i32>>
|
|
||||||
+ Into<Option<&'a String>>
|
|
||||||
+ Into<Option<&'a f64>>,
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The default scalar value representation in juniper
|
/// The default scalar value representation in juniper
|
||||||
///
|
///
|
||||||
/// This types closely follows the graphql specification.
|
/// This types closely follows the graphql specification.
|
||||||
|
@ -270,13 +244,6 @@ impl ScalarValue for DefaultScalarValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_string(&self) -> Option<String> {
|
|
||||||
match *self {
|
|
||||||
DefaultScalarValue::String(ref s) => Some(s.clone()),
|
|
||||||
_ => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn as_float(&self) -> Option<f64> {
|
fn as_float(&self) -> Option<f64> {
|
||||||
match *self {
|
match *self {
|
||||||
DefaultScalarValue::Int(ref i) => Some(*i as f64),
|
DefaultScalarValue::Int(ref i) => Some(*i as f64),
|
||||||
|
@ -285,6 +252,20 @@ impl ScalarValue for DefaultScalarValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn as_str(&self) -> Option<&str> {
|
||||||
|
match *self {
|
||||||
|
DefaultScalarValue::String(ref s) => Some(s.as_str()),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn as_string(&self) -> Option<String> {
|
||||||
|
match *self {
|
||||||
|
DefaultScalarValue::String(ref s) => Some(s.clone()),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn as_boolean(&self) -> Option<bool> {
|
fn as_boolean(&self) -> Option<bool> {
|
||||||
match *self {
|
match *self {
|
||||||
DefaultScalarValue::Boolean(ref b) => Some(*b),
|
DefaultScalarValue::Boolean(ref b) => Some(*b),
|
||||||
|
|
|
@ -211,7 +211,6 @@ pub fn impl_enum(ast: &syn::DeriveInput, is_internal: bool) -> TokenStream {
|
||||||
impl<__S> #juniper_path::GraphQLTypeAsync<__S> for #ident
|
impl<__S> #juniper_path::GraphQLTypeAsync<__S> for #ident
|
||||||
where
|
where
|
||||||
__S: #juniper_path::ScalarValue + Send + Sync,
|
__S: #juniper_path::ScalarValue + Send + Sync,
|
||||||
for<'__b> &'__b __S: #juniper_path::ScalarRefValue<'__b>
|
|
||||||
{
|
{
|
||||||
fn resolve_async<'a>(
|
fn resolve_async<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
@ -234,7 +233,6 @@ pub fn impl_enum(ast: &syn::DeriveInput, is_internal: bool) -> TokenStream {
|
||||||
impl<__S> #juniper_path::GraphQLType<__S> for #ident
|
impl<__S> #juniper_path::GraphQLType<__S> for #ident
|
||||||
where __S:
|
where __S:
|
||||||
#juniper_path::ScalarValue,
|
#juniper_path::ScalarValue,
|
||||||
for<'__b> &'__b __S: #juniper_path::ScalarRefValue<'__b>
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -268,10 +266,9 @@ pub fn impl_enum(ast: &syn::DeriveInput, is_internal: bool) -> TokenStream {
|
||||||
|
|
||||||
impl<__S: #juniper_path::ScalarValue> #juniper_path::FromInputValue<__S> for #ident {
|
impl<__S: #juniper_path::ScalarValue> #juniper_path::FromInputValue<__S> for #ident {
|
||||||
fn from_input_value(v: &#juniper_path::InputValue<__S>) -> Option<#ident>
|
fn from_input_value(v: &#juniper_path::InputValue<__S>) -> Option<#ident>
|
||||||
where for<'__b> &'__b __S: #juniper_path::ScalarRefValue<'__b>
|
|
||||||
{
|
{
|
||||||
match v.as_enum_value().or_else(|| {
|
match v.as_enum_value().or_else(|| {
|
||||||
v.as_scalar_value::<String>().map(|s| s as &str)
|
v.as_string_value()
|
||||||
}) {
|
}) {
|
||||||
#from_inputs
|
#from_inputs
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|
|
@ -157,6 +157,25 @@ pub fn impl_input_object(ast: &syn::DeriveInput, is_internal: bool) -> TokenStre
|
||||||
let mut from_inputs = TokenStream::new();
|
let mut from_inputs = TokenStream::new();
|
||||||
let mut to_inputs = TokenStream::new();
|
let mut to_inputs = TokenStream::new();
|
||||||
|
|
||||||
|
let (_, ty_generics, _) = generics.split_for_impl();
|
||||||
|
|
||||||
|
let mut generics = generics.clone();
|
||||||
|
|
||||||
|
let scalar = if let Some(scalar) = attrs.scalar {
|
||||||
|
scalar
|
||||||
|
} else {
|
||||||
|
generics.params.push(parse_quote!(__S));
|
||||||
|
{
|
||||||
|
let where_clause = generics.where_clause.get_or_insert(parse_quote!(where));
|
||||||
|
where_clause
|
||||||
|
.predicates
|
||||||
|
.push(parse_quote!(__S: #juniper_path::ScalarValue));
|
||||||
|
}
|
||||||
|
Ident::new("__S", Span::call_site())
|
||||||
|
};
|
||||||
|
|
||||||
|
let (impl_generics, _, where_clause) = generics.split_for_impl();
|
||||||
|
|
||||||
for field in fields {
|
for field in fields {
|
||||||
let field_ty = &field.ty;
|
let field_ty = &field.ty;
|
||||||
let field_attrs = ObjFieldAttrs::from_input(field);
|
let field_attrs = ObjFieldAttrs::from_input(field);
|
||||||
|
@ -241,7 +260,7 @@ pub fn impl_input_object(ast: &syn::DeriveInput, is_internal: bool) -> TokenStre
|
||||||
#from_input_default
|
#from_input_default
|
||||||
Some(ref v) => #juniper_path::FromInputValue::from_input_value(v).unwrap(),
|
Some(ref v) => #juniper_path::FromInputValue::from_input_value(v).unwrap(),
|
||||||
None => {
|
None => {
|
||||||
#juniper_path::FromInputValue::from_input_value(&#juniper_path::InputValue::null())
|
#juniper_path::FromInputValue::from_input_value(&#juniper_path::InputValue::<#scalar>::null())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -254,28 +273,6 @@ pub fn impl_input_object(ast: &syn::DeriveInput, is_internal: bool) -> TokenStre
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let (_, ty_generics, _) = generics.split_for_impl();
|
|
||||||
|
|
||||||
let mut generics = generics.clone();
|
|
||||||
|
|
||||||
let scalar = if let Some(scalar) = attrs.scalar {
|
|
||||||
scalar
|
|
||||||
} else {
|
|
||||||
generics.params.push(parse_quote!(__S));
|
|
||||||
{
|
|
||||||
let where_clause = generics.where_clause.get_or_insert(parse_quote!(where));
|
|
||||||
where_clause
|
|
||||||
.predicates
|
|
||||||
.push(parse_quote!(__S: #juniper_path::ScalarValue));
|
|
||||||
where_clause
|
|
||||||
.predicates
|
|
||||||
.push(parse_quote!(for<'__b> &'__b __S: #juniper_path::ScalarRefValue<'__b>));
|
|
||||||
}
|
|
||||||
Ident::new("__S", Span::call_site())
|
|
||||||
};
|
|
||||||
|
|
||||||
let (impl_generics, _, where_clause) = generics.split_for_impl();
|
|
||||||
|
|
||||||
let body = quote! {
|
let body = quote! {
|
||||||
impl#impl_generics #juniper_path::GraphQLType<#scalar> for #ident #ty_generics
|
impl#impl_generics #juniper_path::GraphQLType<#scalar> for #ident #ty_generics
|
||||||
#where_clause
|
#where_clause
|
||||||
|
@ -306,8 +303,6 @@ pub fn impl_input_object(ast: &syn::DeriveInput, is_internal: bool) -> TokenStre
|
||||||
#where_clause
|
#where_clause
|
||||||
{
|
{
|
||||||
fn from_input_value(value: &#juniper_path::InputValue<#scalar>) -> Option<Self>
|
fn from_input_value(value: &#juniper_path::InputValue<#scalar>) -> Option<Self>
|
||||||
where
|
|
||||||
for<'__b> &'__b #scalar: #juniper_path::ScalarRefValue<'__b>
|
|
||||||
{
|
{
|
||||||
if let Some(obj) = value.to_object_value() {
|
if let Some(obj) = value.to_object_value() {
|
||||||
let item = #ident {
|
let item = #ident {
|
||||||
|
|
|
@ -114,7 +114,6 @@ fn impl_scalar_struct(
|
||||||
impl<S> #crate_name::GraphQLType<S> for #ident
|
impl<S> #crate_name::GraphQLType<S> for #ident
|
||||||
where
|
where
|
||||||
S: #crate_name::ScalarValue,
|
S: #crate_name::ScalarValue,
|
||||||
for<'__b> &'__b S: #crate_name::ScalarRefValue<'__b>,
|
|
||||||
{
|
{
|
||||||
type Context = ();
|
type Context = ();
|
||||||
type TypeInfo = ();
|
type TypeInfo = ();
|
||||||
|
@ -128,7 +127,6 @@ fn impl_scalar_struct(
|
||||||
registry: &mut #crate_name::Registry<'r, S>,
|
registry: &mut #crate_name::Registry<'r, S>,
|
||||||
) -> #crate_name::meta::MetaType<'r, S>
|
) -> #crate_name::meta::MetaType<'r, S>
|
||||||
where
|
where
|
||||||
for<'__b> &'__b S: #crate_name::ScalarRefValue<'__b>,
|
|
||||||
S: 'r,
|
S: 'r,
|
||||||
{
|
{
|
||||||
registry.build_scalar_type::<Self>(info)
|
registry.build_scalar_type::<Self>(info)
|
||||||
|
@ -149,7 +147,6 @@ fn impl_scalar_struct(
|
||||||
impl<S> #crate_name::ToInputValue<S> for #ident
|
impl<S> #crate_name::ToInputValue<S> for #ident
|
||||||
where
|
where
|
||||||
S: #crate_name::ScalarValue,
|
S: #crate_name::ScalarValue,
|
||||||
for<'__b> &'__b S: #crate_name::ScalarRefValue<'__b>,
|
|
||||||
{
|
{
|
||||||
fn to_input_value(&self) -> #crate_name::InputValue<S> {
|
fn to_input_value(&self) -> #crate_name::InputValue<S> {
|
||||||
#crate_name::ToInputValue::to_input_value(&self.0)
|
#crate_name::ToInputValue::to_input_value(&self.0)
|
||||||
|
@ -159,7 +156,6 @@ fn impl_scalar_struct(
|
||||||
impl<S> #crate_name::FromInputValue<S> for #ident
|
impl<S> #crate_name::FromInputValue<S> for #ident
|
||||||
where
|
where
|
||||||
S: #crate_name::ScalarValue,
|
S: #crate_name::ScalarValue,
|
||||||
for<'__b> &'__b S: #crate_name::ScalarRefValue<'__b>,
|
|
||||||
{
|
{
|
||||||
fn from_input_value(v: &#crate_name::InputValue<S>) -> Option<#ident> {
|
fn from_input_value(v: &#crate_name::InputValue<S>) -> Option<#ident> {
|
||||||
let inner: #inner_ty = #crate_name::FromInputValue::from_input_value(v)?;
|
let inner: #inner_ty = #crate_name::FromInputValue::from_input_value(v)?;
|
||||||
|
@ -170,7 +166,6 @@ fn impl_scalar_struct(
|
||||||
impl<S> #crate_name::ParseScalarValue<S> for #ident
|
impl<S> #crate_name::ParseScalarValue<S> for #ident
|
||||||
where
|
where
|
||||||
S: #crate_name::ScalarValue,
|
S: #crate_name::ScalarValue,
|
||||||
for<'__b> &'__b S: #crate_name::ScalarRefValue<'__b>,
|
|
||||||
{
|
{
|
||||||
fn from_str<'a>(
|
fn from_str<'a>(
|
||||||
value: #crate_name::parser::ScalarToken<'a>,
|
value: #crate_name::parser::ScalarToken<'a>,
|
||||||
|
|
|
@ -132,19 +132,7 @@ pub fn impl_union(
|
||||||
.map(|s| quote!( #s ))
|
.map(|s| quote!( #s ))
|
||||||
.unwrap_or_else(|| { quote! { #juniper::DefaultScalarValue } });
|
.unwrap_or_else(|| { quote! { #juniper::DefaultScalarValue } });
|
||||||
|
|
||||||
let mut generics = item.generics.clone();
|
let generics = item.generics.clone();
|
||||||
if attrs.scalar.is_some() {
|
|
||||||
// A custom scalar type was specified.
|
|
||||||
// Therefore, we always insert a where clause that marks the scalar as
|
|
||||||
// compatible with ScalarValueRef.
|
|
||||||
// This is done to prevent the user from having to specify this
|
|
||||||
// manually.
|
|
||||||
let where_clause = generics.where_clause.get_or_insert(syn::parse_quote!(where));
|
|
||||||
where_clause.predicates.push(
|
|
||||||
syn::parse_quote!(for<'__b> &'__b #scalar: #juniper::ScalarRefValue<'__b>),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
let (impl_generics, _, where_clause) = generics.split_for_impl();
|
let (impl_generics, _, where_clause) = generics.split_for_impl();
|
||||||
|
|
||||||
let description = match attrs.description.as_ref() {
|
let description = match attrs.description.as_ref() {
|
||||||
|
@ -168,7 +156,6 @@ pub fn impl_union(
|
||||||
registry: &mut #juniper::Registry<'r, #scalar>
|
registry: &mut #juniper::Registry<'r, #scalar>
|
||||||
) -> #juniper::meta::MetaType<'r, #scalar>
|
) -> #juniper::meta::MetaType<'r, #scalar>
|
||||||
where
|
where
|
||||||
for<'__b> &'__b #scalar: #juniper::ScalarRefValue<'__b>,
|
|
||||||
#scalar: 'r,
|
#scalar: 'r,
|
||||||
{
|
{
|
||||||
let types = &[
|
let types = &[
|
||||||
|
|
|
@ -809,15 +809,6 @@ impl GraphQLTypeDefiniton {
|
||||||
let mut generics = self.generics.clone();
|
let mut generics = self.generics.clone();
|
||||||
|
|
||||||
if self.scalar.is_some() {
|
if self.scalar.is_some() {
|
||||||
// A custom scalar type was specified.
|
|
||||||
// Therefore, we always insert a where clause that marks the scalar as
|
|
||||||
// compatible with ScalarValueRef.
|
|
||||||
// This is done to prevent the user from having to specify this
|
|
||||||
// manually.
|
|
||||||
let where_clause = generics.where_clause.get_or_insert(parse_quote!(where));
|
|
||||||
where_clause.predicates.push(
|
|
||||||
parse_quote!(for<'__b> &'__b #scalar: #juniper_crate_name::ScalarRefValue<'__b>),
|
|
||||||
);
|
|
||||||
} else if self.generic_scalar {
|
} else if self.generic_scalar {
|
||||||
// No custom scalar specified, but always generic specified.
|
// No custom scalar specified, but always generic specified.
|
||||||
// Therefore we inject the generic scalar.
|
// Therefore we inject the generic scalar.
|
||||||
|
@ -829,12 +820,6 @@ impl GraphQLTypeDefiniton {
|
||||||
where_clause
|
where_clause
|
||||||
.predicates
|
.predicates
|
||||||
.push(parse_quote!(__S: #juniper_crate_name::ScalarValue));
|
.push(parse_quote!(__S: #juniper_crate_name::ScalarValue));
|
||||||
// Insert a where clause that marks the scalar as
|
|
||||||
// compatible with ScalarValueRef.
|
|
||||||
// Same as in branch above.
|
|
||||||
where_clause
|
|
||||||
.predicates
|
|
||||||
.push(parse_quote!(for<'__b> &'__b __S: #juniper_crate_name::ScalarRefValue<'__b>));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let type_generics_tokens = if self.include_type_generics {
|
let type_generics_tokens = if self.include_type_generics {
|
||||||
|
@ -976,7 +961,6 @@ impl GraphQLTypeDefiniton {
|
||||||
registry: &mut #juniper_crate_name::Registry<'r, #scalar>
|
registry: &mut #juniper_crate_name::Registry<'r, #scalar>
|
||||||
) -> #juniper_crate_name::meta::MetaType<'r, #scalar>
|
) -> #juniper_crate_name::meta::MetaType<'r, #scalar>
|
||||||
where #scalar : 'r,
|
where #scalar : 'r,
|
||||||
for<'z> &'z #scalar: #juniper_crate_name::ScalarRefValue<'z>,
|
|
||||||
{
|
{
|
||||||
let fields = vec![
|
let fields = vec![
|
||||||
#( #field_definitions ),*
|
#( #field_definitions ),*
|
||||||
|
|
|
@ -11,7 +11,7 @@ use hyper::{
|
||||||
};
|
};
|
||||||
use juniper::{
|
use juniper::{
|
||||||
http::GraphQLRequest as JuniperGraphQLRequest, serde::Deserialize, DefaultScalarValue,
|
http::GraphQLRequest as JuniperGraphQLRequest, serde::Deserialize, DefaultScalarValue,
|
||||||
GraphQLType, InputValue, RootNode, ScalarRefValue, ScalarValue,
|
GraphQLType, InputValue, RootNode, ScalarValue,
|
||||||
};
|
};
|
||||||
use serde_json::error::Error as SerdeError;
|
use serde_json::error::Error as SerdeError;
|
||||||
use std::{error::Error, fmt, string::FromUtf8Error, sync::Arc};
|
use std::{error::Error, fmt, string::FromUtf8Error, sync::Arc};
|
||||||
|
@ -25,7 +25,6 @@ pub fn graphql<CtxT, QueryT, MutationT, S>(
|
||||||
) -> impl Future<Item = Response<Body>, Error = hyper::Error>
|
) -> impl Future<Item = Response<Body>, Error = hyper::Error>
|
||||||
where
|
where
|
||||||
S: ScalarValue + Send + Sync + 'static,
|
S: ScalarValue + Send + Sync + 'static,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
CtxT: Send + Sync + 'static,
|
CtxT: Send + Sync + 'static,
|
||||||
QueryT: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
|
QueryT: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
|
||||||
MutationT: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
|
MutationT: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
|
||||||
|
@ -111,7 +110,6 @@ fn execute_request<CtxT, QueryT, MutationT, S>(
|
||||||
) -> impl Future<Item = Response<Body>, Error = tokio_threadpool::BlockingError>
|
) -> impl Future<Item = Response<Body>, Error = tokio_threadpool::BlockingError>
|
||||||
where
|
where
|
||||||
S: ScalarValue + Send + Sync + 'static,
|
S: ScalarValue + Send + Sync + 'static,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
CtxT: Send + Sync + 'static,
|
CtxT: Send + Sync + 'static,
|
||||||
QueryT: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
|
QueryT: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
|
||||||
MutationT: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
|
MutationT: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
|
||||||
|
@ -212,7 +210,6 @@ where
|
||||||
impl<S> GraphQLRequest<S>
|
impl<S> GraphQLRequest<S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
fn execute<'a, CtxT: 'a, QueryT, MutationT>(
|
fn execute<'a, CtxT: 'a, QueryT, MutationT>(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -119,7 +119,7 @@ use serde_json::error::Error as SerdeError;
|
||||||
|
|
||||||
use juniper::{
|
use juniper::{
|
||||||
http, serde::Deserialize, DefaultScalarValue, GraphQLType, InputValue, RootNode,
|
http, serde::Deserialize, DefaultScalarValue, GraphQLType, InputValue, RootNode,
|
||||||
ScalarRefValue, ScalarValue,
|
ScalarValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(serde_derive::Deserialize)]
|
#[derive(serde_derive::Deserialize)]
|
||||||
|
@ -146,7 +146,6 @@ where
|
||||||
impl<S> GraphQLBatchRequest<S>
|
impl<S> GraphQLBatchRequest<S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
pub fn execute<'a, CtxT, QueryT, MutationT>(
|
pub fn execute<'a, CtxT, QueryT, MutationT>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
@ -198,7 +197,6 @@ where
|
||||||
pub struct GraphQLHandler<'a, CtxFactory, Query, Mutation, CtxT, S = DefaultScalarValue>
|
pub struct GraphQLHandler<'a, CtxFactory, Query, Mutation, CtxT, S = DefaultScalarValue>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
CtxFactory: Fn(&mut Request) -> IronResult<CtxT> + Send + Sync + 'static,
|
CtxFactory: Fn(&mut Request) -> IronResult<CtxT> + Send + Sync + 'static,
|
||||||
CtxT: 'static,
|
CtxT: 'static,
|
||||||
Query: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
|
Query: GraphQLType<S, Context = CtxT> + Send + Sync + 'static,
|
||||||
|
@ -253,7 +251,6 @@ impl<'a, CtxFactory, Query, Mutation, CtxT, S>
|
||||||
GraphQLHandler<'a, CtxFactory, Query, Mutation, CtxT, S>
|
GraphQLHandler<'a, CtxFactory, Query, Mutation, CtxT, S>
|
||||||
where
|
where
|
||||||
S: ScalarValue + 'a,
|
S: ScalarValue + 'a,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
CtxFactory: Fn(&mut Request) -> IronResult<CtxT> + Send + Sync + 'static,
|
CtxFactory: Fn(&mut Request) -> IronResult<CtxT> + Send + Sync + 'static,
|
||||||
CtxT: 'static,
|
CtxT: 'static,
|
||||||
Query: GraphQLType<S, Context = CtxT, TypeInfo = ()> + Send + Sync + 'static,
|
Query: GraphQLType<S, Context = CtxT, TypeInfo = ()> + Send + Sync + 'static,
|
||||||
|
@ -340,7 +337,6 @@ impl<'a, CtxFactory, Query, Mutation, CtxT, S> Handler
|
||||||
for GraphQLHandler<'a, CtxFactory, Query, Mutation, CtxT, S>
|
for GraphQLHandler<'a, CtxFactory, Query, Mutation, CtxT, S>
|
||||||
where
|
where
|
||||||
S: ScalarValue + Sync + Send + 'static,
|
S: ScalarValue + Sync + Send + 'static,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
CtxFactory: Fn(&mut Request) -> IronResult<CtxT> + Send + Sync + 'static,
|
CtxFactory: Fn(&mut Request) -> IronResult<CtxT> + Send + Sync + 'static,
|
||||||
CtxT: 'static,
|
CtxT: 'static,
|
||||||
Query: GraphQLType<S, Context = CtxT, TypeInfo = ()> + Send + Sync + 'static,
|
Query: GraphQLType<S, Context = CtxT, TypeInfo = ()> + Send + Sync + 'static,
|
||||||
|
|
|
@ -54,7 +54,7 @@ use rocket::{
|
||||||
use juniper::{http, InputValue};
|
use juniper::{http, InputValue};
|
||||||
|
|
||||||
use juniper::{
|
use juniper::{
|
||||||
serde::Deserialize, DefaultScalarValue, FieldError, GraphQLType, RootNode, ScalarRefValue,
|
serde::Deserialize, DefaultScalarValue, FieldError, GraphQLType, RootNode,
|
||||||
ScalarValue,
|
ScalarValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -88,7 +88,6 @@ where
|
||||||
impl<S> GraphQLBatchRequest<S>
|
impl<S> GraphQLBatchRequest<S>
|
||||||
where
|
where
|
||||||
S: ScalarValue + Send + Sync,
|
S: ScalarValue + Send + Sync,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
pub fn execute<'a, CtxT, QueryT, MutationT>(
|
pub fn execute<'a, CtxT, QueryT, MutationT>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
@ -192,7 +191,6 @@ pub fn playground_source(graphql_endpoint_url: &str) -> content::Html<String> {
|
||||||
impl<S> GraphQLRequest<S>
|
impl<S> GraphQLRequest<S>
|
||||||
where
|
where
|
||||||
S: ScalarValue + Sync + Send,
|
S: ScalarValue + Sync + Send,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
/// Execute an incoming GraphQL query
|
/// Execute an incoming GraphQL query
|
||||||
pub fn execute<CtxT, QueryT, MutationT>(
|
pub fn execute<CtxT, QueryT, MutationT>(
|
||||||
|
|
|
@ -48,7 +48,7 @@ use warp::{filters::BoxedFilter, Filter};
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
use futures03::future::{FutureExt, TryFutureExt};
|
use futures03::future::{FutureExt, TryFutureExt};
|
||||||
|
|
||||||
use juniper::{DefaultScalarValue, InputValue, ScalarRefValue, ScalarValue};
|
use juniper::{DefaultScalarValue, InputValue, ScalarValue};
|
||||||
|
|
||||||
#[derive(Debug, serde_derive::Deserialize, PartialEq)]
|
#[derive(Debug, serde_derive::Deserialize, PartialEq)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
@ -64,7 +64,6 @@ where
|
||||||
impl<S> GraphQLBatchRequest<S>
|
impl<S> GraphQLBatchRequest<S>
|
||||||
where
|
where
|
||||||
S: ScalarValue,
|
S: ScalarValue,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
{
|
{
|
||||||
pub fn execute<'a, CtxT, QueryT, MutationT>(
|
pub fn execute<'a, CtxT, QueryT, MutationT>(
|
||||||
&'a self,
|
&'a self,
|
||||||
|
@ -210,7 +209,6 @@ pub fn make_graphql_filter<Query, Mutation, Context, S>(
|
||||||
) -> BoxedFilter<(warp::http::Response<Vec<u8>>,)>
|
) -> BoxedFilter<(warp::http::Response<Vec<u8>>,)>
|
||||||
where
|
where
|
||||||
S: ScalarValue + Send + Sync + 'static,
|
S: ScalarValue + Send + Sync + 'static,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
Context: Send + 'static,
|
Context: Send + 'static,
|
||||||
Query: juniper::GraphQLType<S, Context = Context, TypeInfo = ()> + Send + Sync + 'static,
|
Query: juniper::GraphQLType<S, Context = Context, TypeInfo = ()> + Send + Sync + 'static,
|
||||||
Mutation: juniper::GraphQLType<S, Context = Context, TypeInfo = ()> + Send + Sync + 'static,
|
Mutation: juniper::GraphQLType<S, Context = Context, TypeInfo = ()> + Send + Sync + 'static,
|
||||||
|
@ -283,7 +281,6 @@ pub fn make_graphql_filter_async<Query, Mutation, Context, S>(
|
||||||
) -> BoxedFilter<(warp::http::Response<Vec<u8>>,)>
|
) -> BoxedFilter<(warp::http::Response<Vec<u8>>,)>
|
||||||
where
|
where
|
||||||
S: ScalarValue + Send + Sync + 'static,
|
S: ScalarValue + Send + Sync + 'static,
|
||||||
for<'b> &'b S: ScalarRefValue<'b>,
|
|
||||||
Context: Send + Sync + 'static,
|
Context: Send + Sync + 'static,
|
||||||
Query: juniper::GraphQLTypeAsync<S, Context = Context> + Send + Sync + 'static,
|
Query: juniper::GraphQLTypeAsync<S, Context = Context> + Send + Sync + 'static,
|
||||||
Query::TypeInfo: Send + Sync,
|
Query::TypeInfo: Send + Sync,
|
||||||
|
|
Loading…
Add table
Reference in a new issue