Make imports consistent
This commit is contained in:
parent
cc115ff1a7
commit
93c886af07
|
@ -10,7 +10,8 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use fnv::FnvHashMap;
|
use fnv::FnvHashMap;
|
||||||
use serde::ser::{SerializeSeq, Serializer};
|
use serde::ser::{SerializeSeq, Serializer};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::de::{Deserialize, Deserializer};
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::extensions::Extensions;
|
use crate::extensions::Extensions;
|
||||||
use crate::parser::types::{
|
use crate::parser::types::{
|
||||||
|
@ -24,7 +25,7 @@ use crate::{
|
||||||
use async_graphql_value::{Name, Value as InputValue};
|
use async_graphql_value::{Name, Value as InputValue};
|
||||||
|
|
||||||
/// Variables of a query.
|
/// Variables of a query.
|
||||||
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
|
#[derive(Debug, Clone, Default, Serialize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
pub struct Variables(pub BTreeMap<Name, Value>);
|
pub struct Variables(pub BTreeMap<Name, Value>);
|
||||||
|
|
||||||
|
@ -38,6 +39,12 @@ impl Display for Variables {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'de> Deserialize<'de> for Variables {
|
||||||
|
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
|
||||||
|
Ok(Self(<Option<BTreeMap<Name, Value>>>::deserialize(deserializer)?.unwrap_or_default()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Variables {
|
impl Variables {
|
||||||
/// Get the variables from a GraphQL value.
|
/// Get the variables from a GraphQL value.
|
||||||
///
|
///
|
||||||
|
@ -127,7 +134,8 @@ pub type Context<'a> = ContextBase<'a, &'a Positioned<Field>>;
|
||||||
///
|
///
|
||||||
/// This is a borrowed form of [`PathSegment`](enum.PathSegment.html) used during execution instead
|
/// This is a borrowed form of [`PathSegment`](enum.PathSegment.html) used during execution instead
|
||||||
/// of passed back when errors occur.
|
/// of passed back when errors occur.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy, Serialize)]
|
||||||
|
#[serde(untagged)]
|
||||||
pub enum QueryPathSegment<'a> {
|
pub enum QueryPathSegment<'a> {
|
||||||
/// We are currently resolving an element in a list.
|
/// We are currently resolving an element in a list.
|
||||||
Index(usize),
|
Index(usize),
|
||||||
|
@ -150,14 +158,7 @@ pub struct QueryPathNode<'a> {
|
||||||
impl<'a> serde::Serialize for QueryPathNode<'a> {
|
impl<'a> serde::Serialize for QueryPathNode<'a> {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
let mut seq = serializer.serialize_seq(None)?;
|
let mut seq = serializer.serialize_seq(None)?;
|
||||||
self.for_each(|segment| match segment {
|
self.try_for_each(|segment| seq.serialize_element(segment))?;
|
||||||
QueryPathSegment::Index(idx) => {
|
|
||||||
seq.serialize_element(&idx).ok();
|
|
||||||
}
|
|
||||||
QueryPathSegment::Name(name) => {
|
|
||||||
seq.serialize_element(name).ok();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
seq.end()
|
seq.end()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,21 +166,21 @@ impl<'a> serde::Serialize for QueryPathNode<'a> {
|
||||||
impl<'a> Display for QueryPathNode<'a> {
|
impl<'a> Display for QueryPathNode<'a> {
|
||||||
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
self.for_each(|segment| {
|
self.try_for_each(|segment| {
|
||||||
if !first {
|
if !first {
|
||||||
write!(f, ".").ok();
|
write!(f, ".")?;
|
||||||
}
|
|
||||||
match segment {
|
|
||||||
QueryPathSegment::Index(idx) => {
|
|
||||||
write!(f, "{}", *idx).ok();
|
|
||||||
}
|
|
||||||
QueryPathSegment::Name(name) => {
|
|
||||||
write!(f, "{}", name).ok();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
first = false;
|
first = false;
|
||||||
});
|
|
||||||
Ok(())
|
match segment {
|
||||||
|
QueryPathSegment::Index(idx) => {
|
||||||
|
write!(f, "{}", *idx)
|
||||||
|
}
|
||||||
|
QueryPathSegment::Name(name) => {
|
||||||
|
write!(f, "{}", name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +205,7 @@ impl<'a> QueryPathNode<'a> {
|
||||||
res.push(match s {
|
res.push(match s {
|
||||||
QueryPathSegment::Name(name) => name.to_string(),
|
QueryPathSegment::Name(name) => name.to_string(),
|
||||||
QueryPathSegment::Index(idx) => idx.to_string(),
|
QueryPathSegment::Index(idx) => idx.to_string(),
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
@ -215,14 +216,27 @@ impl<'a> QueryPathNode<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn for_each<F: FnMut(&QueryPathSegment<'a>)>(&self, mut f: F) {
|
pub(crate) fn for_each<F: FnMut(&QueryPathSegment<'a>)>(&self, mut f: F) {
|
||||||
self.for_each_ref(&mut f);
|
let _ = self.try_for_each::<std::convert::Infallible, _>(|segment| {
|
||||||
|
f(segment);
|
||||||
|
Ok(())
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn for_each_ref<F: FnMut(&QueryPathSegment<'a>)>(&self, f: &mut F) {
|
pub(crate) fn try_for_each<E, F: FnMut(&QueryPathSegment<'a>) -> Result<(), E>>(
|
||||||
|
&self,
|
||||||
|
mut f: F,
|
||||||
|
) -> Result<(), E> {
|
||||||
|
self.try_for_each_ref(&mut f)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn try_for_each_ref<E, F: FnMut(&QueryPathSegment<'a>) -> Result<(), E>>(
|
||||||
|
&self,
|
||||||
|
f: &mut F,
|
||||||
|
) -> Result<(), E> {
|
||||||
if let Some(parent) = &self.parent {
|
if let Some(parent) = &self.parent {
|
||||||
parent.for_each_ref(f);
|
parent.try_for_each_ref(f)?;
|
||||||
}
|
}
|
||||||
f(&self.segment);
|
f(&self.segment)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +266,7 @@ impl<'a> Iterator for Parents<'a> {
|
||||||
|
|
||||||
impl<'a> std::iter::FusedIterator for Parents<'a> {}
|
impl<'a> std::iter::FusedIterator for Parents<'a> {}
|
||||||
|
|
||||||
/// The unique id of the current resolusion.
|
/// The unique id of the current resolution.
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct ResolveId {
|
pub struct ResolveId {
|
||||||
/// The unique ID of the parent resolution.
|
/// The unique ID of the parent resolution.
|
||||||
|
|
18
src/error.rs
18
src/error.rs
|
@ -1,10 +1,12 @@
|
||||||
use crate::{parser, InputValueType, Pos, Value};
|
|
||||||
use serde::Serialize;
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fmt::{self, Debug, Display, Formatter};
|
use std::fmt::{self, Debug, Display, Formatter};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
use crate::{parser, InputValueType, Pos, Value};
|
||||||
|
|
||||||
/// Extensions to the error.
|
/// Extensions to the error.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Default)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
|
@ -34,10 +36,7 @@ pub struct ServerError {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn error_extensions_is_empty(values: &Option<ErrorExtensionValues>) -> bool {
|
fn error_extensions_is_empty(values: &Option<ErrorExtensionValues>) -> bool {
|
||||||
match values {
|
values.as_ref().map_or(false, |values| values.0.is_empty())
|
||||||
Some(values) => values.0.is_empty(),
|
|
||||||
None => true,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServerError {
|
impl ServerError {
|
||||||
|
@ -94,6 +93,9 @@ impl From<parser::Error> for ServerError {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A segment of path to a resolver.
|
/// A segment of path to a resolver.
|
||||||
|
///
|
||||||
|
/// This is like [`QueryPathSegment`](enum.QueryPathSegment.html), but owned and used as a part of
|
||||||
|
/// errors instead of during execution.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
pub enum PathSegment {
|
pub enum PathSegment {
|
||||||
|
@ -268,7 +270,7 @@ impl From<multer::Error> for ParseRequestError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An error which can be extended into a `FieldError`.
|
/// An error which can be extended into a `Error`.
|
||||||
pub trait ErrorExtensions: Sized {
|
pub trait ErrorExtensions: Sized {
|
||||||
/// Convert the error to a `Error`.
|
/// Convert the error to a `Error`.
|
||||||
fn extend(&self) -> Error;
|
fn extend(&self) -> Error;
|
||||||
|
@ -299,7 +301,7 @@ impl ErrorExtensions for Error {
|
||||||
impl<E: std::fmt::Display> ErrorExtensions for &E {
|
impl<E: std::fmt::Display> ErrorExtensions for &E {
|
||||||
fn extend(&self) -> Error {
|
fn extend(&self) -> Error {
|
||||||
Error {
|
Error {
|
||||||
message: format!("{}", self),
|
message: self.to_string(),
|
||||||
extensions: None,
|
extensions: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
//! Apollo persisted queries extension.
|
//! Apollo persisted queries extension.
|
||||||
|
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use futures::lock::Mutex;
|
||||||
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::extensions::{Extension, ExtensionContext, ExtensionFactory};
|
use crate::extensions::{Extension, ExtensionContext, ExtensionFactory};
|
||||||
use crate::{from_value, Request, ServerError, ServerResult};
|
use crate::{from_value, Request, ServerError, ServerResult};
|
||||||
use futures::lock::Mutex;
|
|
||||||
use serde::Deserialize;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct PersistedQuery {
|
struct PersistedQuery {
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
use crate::extensions::{Extension, ExtensionContext, ExtensionFactory, ResolveInfo};
|
|
||||||
use crate::{value, Value, Variables};
|
|
||||||
use chrono::{DateTime, Utc};
|
|
||||||
use serde::ser::SerializeMap;
|
|
||||||
use serde::{Serialize, Serializer};
|
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
|
use serde::ser::SerializeMap;
|
||||||
|
use serde::{Serialize, Serializer};
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
|
use crate::extensions::{Extension, ExtensionContext, ExtensionFactory, ResolveInfo};
|
||||||
|
use crate::{value, Value, Variables};
|
||||||
|
|
||||||
struct PendingResolve {
|
struct PendingResolve {
|
||||||
path: Vec<String>,
|
path: Vec<String>,
|
||||||
field_name: String,
|
field_name: String,
|
||||||
|
@ -29,7 +31,7 @@ impl Deref for ResolveStat {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Serialize for ResolveStat {
|
impl Serialize for ResolveStat {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
let mut map = serializer.serialize_map(None)?;
|
let mut map = serializer.serialize_map(None)?;
|
||||||
map.serialize_entry("path", &self.path)?;
|
map.serialize_entry("path", &self.path)?;
|
||||||
map.serialize_entry("fieldName", &self.field_name)?;
|
map.serialize_entry("fieldName", &self.field_name)?;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
|
use log::{error, info, trace};
|
||||||
|
|
||||||
use crate::extensions::{Extension, ExtensionContext, ExtensionFactory, ResolveInfo};
|
use crate::extensions::{Extension, ExtensionContext, ExtensionFactory, ResolveInfo};
|
||||||
use crate::parser::types::{ExecutableDocument, OperationType, Selection};
|
use crate::parser::types::{ExecutableDocument, OperationType, Selection};
|
||||||
use crate::{PathSegment, ServerError, Variables};
|
use crate::{PathSegment, ServerError, Variables};
|
||||||
use log::{error, info, trace};
|
|
||||||
use std::fmt::{self, Display, Formatter};
|
|
||||||
|
|
||||||
/// Logger extension
|
/// Logger extension
|
||||||
#[cfg_attr(feature = "nightly", doc(cfg(feature = "log")))]
|
#[cfg_attr(feature = "nightly", doc(cfg(feature = "log")))]
|
||||||
|
|
|
@ -9,8 +9,13 @@ mod logger;
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
mod tracing;
|
mod tracing;
|
||||||
|
|
||||||
|
use std::any::{Any, TypeId};
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use crate::context::{QueryPathNode, ResolveId};
|
use crate::context::{QueryPathNode, ResolveId};
|
||||||
use crate::{Data, Request, Result, ServerError, ServerResult, Variables};
|
use crate::{Data, Request, Result, ServerError, ServerResult, Variables};
|
||||||
|
use crate::parser::types::ExecutableDocument;
|
||||||
|
use crate::{Error, Name, Value};
|
||||||
|
|
||||||
#[cfg(feature = "apollo_tracing")]
|
#[cfg(feature = "apollo_tracing")]
|
||||||
pub use self::apollo_tracing::ApolloTracing;
|
pub use self::apollo_tracing::ApolloTracing;
|
||||||
|
@ -18,10 +23,6 @@ pub use self::apollo_tracing::ApolloTracing;
|
||||||
pub use self::logger::Logger;
|
pub use self::logger::Logger;
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
pub use self::tracing::Tracing;
|
pub use self::tracing::Tracing;
|
||||||
use crate::parser::types::ExecutableDocument;
|
|
||||||
use crate::{Error, Name, Value};
|
|
||||||
use std::any::{Any, TypeId};
|
|
||||||
use std::collections::BTreeMap;
|
|
||||||
|
|
||||||
pub(crate) type BoxExtension = Box<dyn Extension>;
|
pub(crate) type BoxExtension = Box<dyn Extension>;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
|
use tracing::{span, Level, Span};
|
||||||
|
|
||||||
use crate::extensions::{Extension, ExtensionContext, ExtensionFactory, ResolveInfo};
|
use crate::extensions::{Extension, ExtensionContext, ExtensionFactory, ResolveInfo};
|
||||||
use crate::{ServerError, Variables};
|
use crate::{ServerError, Variables};
|
||||||
use async_graphql_parser::types::ExecutableDocument;
|
use crate::parser::types::ExecutableDocument;
|
||||||
use std::collections::BTreeMap;
|
|
||||||
use tracing::{span, Level, Span};
|
|
||||||
|
|
||||||
/// Tracing extension
|
/// Tracing extension
|
||||||
///
|
///
|
||||||
|
|
|
@ -6,16 +6,17 @@ mod multipart;
|
||||||
mod playground_source;
|
mod playground_source;
|
||||||
mod websocket;
|
mod websocket;
|
||||||
|
|
||||||
|
use futures::io::AsyncRead;
|
||||||
|
use futures::AsyncReadExt;
|
||||||
|
|
||||||
|
use crate::{BatchRequest, ParseRequestError, Request};
|
||||||
|
|
||||||
pub use graphiql_source::graphiql_source;
|
pub use graphiql_source::graphiql_source;
|
||||||
#[cfg(feature = "multipart")]
|
#[cfg(feature = "multipart")]
|
||||||
pub use multipart::MultipartOptions;
|
pub use multipart::MultipartOptions;
|
||||||
pub use playground_source::{playground_source, GraphQLPlaygroundConfig};
|
pub use playground_source::{playground_source, GraphQLPlaygroundConfig};
|
||||||
pub use websocket::WebSocket;
|
pub use websocket::WebSocket;
|
||||||
|
|
||||||
use crate::{BatchRequest, ParseRequestError, Request};
|
|
||||||
use futures::io::AsyncRead;
|
|
||||||
use futures::AsyncReadExt;
|
|
||||||
|
|
||||||
#[cfg(feature = "multipart")]
|
#[cfg(feature = "multipart")]
|
||||||
#[cfg_attr(feature = "nightly", doc(cfg(feature = "multipart")))]
|
#[cfg_attr(feature = "nightly", doc(cfg(feature = "multipart")))]
|
||||||
/// Receive a GraphQL request from a content type and body.
|
/// Receive a GraphQL request from a content type and body.
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
use crate::{BatchRequest, ParseRequestError, UploadValue};
|
use std::collections::HashMap;
|
||||||
|
use std::io::{self, Seek, SeekFrom, Write};
|
||||||
|
use std::pin::Pin;
|
||||||
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::io::AsyncRead;
|
use futures::io::AsyncRead;
|
||||||
use futures::stream::Stream;
|
use futures::stream::Stream;
|
||||||
use multer::{Constraints, Multipart, SizeLimit};
|
use multer::{Constraints, Multipart, SizeLimit};
|
||||||
use pin_project_lite::pin_project;
|
use pin_project_lite::pin_project;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::io::{self, Seek, SeekFrom, Write};
|
use crate::{BatchRequest, ParseRequestError, UploadValue};
|
||||||
use std::pin::Pin;
|
|
||||||
use std::task::{Context, Poll};
|
|
||||||
|
|
||||||
/// Options for `receive_multipart`.
|
/// Options for `receive_multipart`.
|
||||||
#[derive(Default, Clone, Copy)]
|
#[derive(Default, Clone, Copy)]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use serde::Serialize;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use serde::Serialize;
|
||||||
|
|
||||||
/// Generate the page for GraphQL Playground
|
/// Generate the page for GraphQL Playground
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
//! WebSocket transport for subscription
|
//! WebSocket transport for subscription
|
||||||
|
|
||||||
use crate::{Data, Error, ObjectType, Request, Response, Result, Schema, SubscriptionType};
|
|
||||||
use futures::Stream;
|
|
||||||
use pin_project_lite::pin_project;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
|
|
||||||
|
use futures::Stream;
|
||||||
|
use pin_project_lite::pin_project;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::{Data, Error, ObjectType, Request, Response, Result, Schema, SubscriptionType};
|
||||||
|
|
||||||
pin_project! {
|
pin_project! {
|
||||||
/// A GraphQL connection over websocket.
|
/// A GraphQL connection over websocket.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::parser::types::{Field, FragmentDefinition, Selection, SelectionSet};
|
use crate::parser::types::{Field, FragmentDefinition, Selection, SelectionSet};
|
||||||
use crate::{Name, Positioned};
|
use crate::{Name, Positioned};
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
/// A selection performed by a query.
|
/// A selection performed by a query.
|
||||||
pub struct Lookahead<'a> {
|
pub struct Lookahead<'a> {
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::model::{__InputValue, __Type};
|
use crate::model::{__InputValue, __Type};
|
||||||
use crate::{registry, Object};
|
use crate::{registry, Object};
|
||||||
use itertools::Itertools;
|
|
||||||
|
|
||||||
pub struct __Field<'a> {
|
pub struct __Field<'a> {
|
||||||
pub registry: &'a registry::Registry,
|
pub registry: &'a registry::Registry,
|
||||||
|
@ -26,7 +25,7 @@ impl<'a> __Field<'a> {
|
||||||
registry: self.registry,
|
registry: self.registry,
|
||||||
input_value,
|
input_value,
|
||||||
})
|
})
|
||||||
.collect_vec()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[graphql(name = "type")]
|
#[graphql(name = "type")]
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::model::{__Directive, __Type};
|
use crate::model::{__Directive, __Type};
|
||||||
use crate::{registry, Object};
|
use crate::{registry, Object};
|
||||||
use itertools::Itertools;
|
|
||||||
|
|
||||||
pub struct __Schema<'a> {
|
pub struct __Schema<'a> {
|
||||||
pub registry: &'a registry::Registry,
|
pub registry: &'a registry::Registry,
|
||||||
|
@ -11,12 +10,12 @@ pub struct __Schema<'a> {
|
||||||
impl<'a> __Schema<'a> {
|
impl<'a> __Schema<'a> {
|
||||||
/// A list of all types supported by this server.
|
/// A list of all types supported by this server.
|
||||||
async fn types(&self) -> Vec<__Type<'a>> {
|
async fn types(&self) -> Vec<__Type<'a>> {
|
||||||
let mut types = self
|
let mut types: Vec<_> = self
|
||||||
.registry
|
.registry
|
||||||
.types
|
.types
|
||||||
.values()
|
.values()
|
||||||
.map(|ty| (ty.name(), __Type::new_simple(self.registry, ty)))
|
.map(|ty| (ty.name(), __Type::new_simple(self.registry, ty)))
|
||||||
.collect_vec();
|
.collect();
|
||||||
types.sort_by(|a, b| a.0.cmp(b.0));
|
types.sort_by(|a, b| a.0.cmp(b.0));
|
||||||
types.into_iter().map(|(_, ty)| ty).collect()
|
types.into_iter().map(|(_, ty)| ty).collect()
|
||||||
}
|
}
|
||||||
|
@ -49,7 +48,7 @@ impl<'a> __Schema<'a> {
|
||||||
|
|
||||||
/// A list of all directives supported by this server.
|
/// A list of all directives supported by this server.
|
||||||
async fn directives(&self) -> Vec<__Directive<'a>> {
|
async fn directives(&self) -> Vec<__Directive<'a>> {
|
||||||
let mut directives = self
|
let mut directives: Vec<_> = self
|
||||||
.registry
|
.registry
|
||||||
.directives
|
.directives
|
||||||
.values()
|
.values()
|
||||||
|
@ -57,7 +56,7 @@ impl<'a> __Schema<'a> {
|
||||||
registry: &self.registry,
|
registry: &self.registry,
|
||||||
directive,
|
directive,
|
||||||
})
|
})
|
||||||
.collect_vec();
|
.collect();
|
||||||
directives.sort_by(|a, b| a.directive.name.cmp(b.directive.name));
|
directives.sort_by(|a, b| a.directive.name.cmp(b.directive.name));
|
||||||
directives
|
directives
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use crate::model::{__EnumValue, __Field, __InputValue, __TypeKind};
|
use crate::model::{__EnumValue, __Field, __InputValue, __TypeKind};
|
||||||
use crate::{registry, Object};
|
use crate::{registry, Object};
|
||||||
use itertools::Itertools;
|
|
||||||
|
|
||||||
enum TypeDetail<'a> {
|
enum TypeDetail<'a> {
|
||||||
Named(&'a registry::MetaType),
|
Named(&'a registry::MetaType),
|
||||||
|
@ -106,7 +105,7 @@ impl<'a> __Type<'a> {
|
||||||
registry: self.registry,
|
registry: self.registry,
|
||||||
field,
|
field,
|
||||||
})
|
})
|
||||||
.collect_vec()
|
.collect()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::registry::{MetaField, MetaInputValue, MetaType, Registry};
|
|
||||||
use itertools::Itertools;
|
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
|
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
|
use crate::registry::{MetaField, MetaInputValue, MetaType, Registry};
|
||||||
|
|
||||||
impl Registry {
|
impl Registry {
|
||||||
pub fn export_sdl(&self, federation: bool) -> String {
|
pub fn export_sdl(&self, federation: bool) -> String {
|
||||||
let mut sdl = String::new();
|
let mut sdl = String::new();
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
mod cache_control;
|
mod cache_control;
|
||||||
mod export_sdl;
|
mod export_sdl;
|
||||||
|
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use indexmap::map::IndexMap;
|
||||||
|
use indexmap::set::IndexSet;
|
||||||
|
|
||||||
use crate::parser::types::{BaseType as ParsedBaseType, Type as ParsedType};
|
use crate::parser::types::{BaseType as ParsedBaseType, Type as ParsedType};
|
||||||
use crate::validators::InputValueValidator;
|
use crate::validators::InputValueValidator;
|
||||||
use crate::{model, Any, Type, Value};
|
use crate::{model, Any, Type, Value};
|
||||||
use indexmap::map::IndexMap;
|
|
||||||
use indexmap::set::IndexSet;
|
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
pub use cache_control::CacheControl;
|
pub use cache_control::CacheControl;
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
use crate::{Data, ParseRequestError, UploadValue, Value, Variables};
|
|
||||||
use serde::{Deserialize, Deserializer};
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::{self, Debug, Formatter};
|
use std::fmt::{self, Debug, Formatter};
|
||||||
|
|
||||||
|
use serde::{Deserialize, Deserializer};
|
||||||
|
|
||||||
|
use crate::{Data, ParseRequestError, UploadValue, Value, Variables};
|
||||||
|
|
||||||
/// GraphQL request.
|
/// GraphQL request.
|
||||||
///
|
///
|
||||||
/// This can be deserialized from a structure of the query string, the operation name and the
|
/// This can be deserialized from a structure of the query string, the operation name and the
|
||||||
|
@ -20,10 +22,10 @@ pub struct Request {
|
||||||
pub operation_name: Option<String>,
|
pub operation_name: Option<String>,
|
||||||
|
|
||||||
/// The variables of the request.
|
/// The variables of the request.
|
||||||
#[serde(default, deserialize_with = "deserialize_variables")]
|
#[serde(default)]
|
||||||
pub variables: Variables,
|
pub variables: Variables,
|
||||||
|
|
||||||
/// Uploads
|
/// Uploads sent with the request.
|
||||||
#[serde(skip)]
|
#[serde(skip)]
|
||||||
pub uploads: Vec<UploadValue>,
|
pub uploads: Vec<UploadValue>,
|
||||||
|
|
||||||
|
@ -38,12 +40,6 @@ pub struct Request {
|
||||||
pub extensions: HashMap<String, Value>,
|
pub extensions: HashMap<String, Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_variables<'de, D: Deserializer<'de>>(
|
|
||||||
deserializer: D,
|
|
||||||
) -> std::result::Result<Variables, D::Error> {
|
|
||||||
Ok(Option::<Variables>::deserialize(deserializer)?.unwrap_or_default())
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Request {
|
impl Request {
|
||||||
/// Create a request object with query source.
|
/// Create a request object with query source.
|
||||||
pub fn new(query: impl Into<String>) -> Self {
|
pub fn new(query: impl Into<String>) -> Self {
|
||||||
|
@ -104,6 +100,7 @@ impl Debug for Request {
|
||||||
.field("query", &self.query)
|
.field("query", &self.query)
|
||||||
.field("operation_name", &self.operation_name)
|
.field("operation_name", &self.operation_name)
|
||||||
.field("variables", &self.variables)
|
.field("variables", &self.variables)
|
||||||
|
.field("extensions", &self.extensions)
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,16 +134,16 @@ impl BatchRequest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_non_empty_vec<'de, D, T>(deserializer: D) -> std::result::Result<Vec<T>, D::Error>
|
fn deserialize_non_empty_vec<'de, D, T>(deserializer: D) -> Result<Vec<T>, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
T: Deserialize<'de>,
|
T: Deserialize<'de>,
|
||||||
{
|
{
|
||||||
use serde::de::Error as _;
|
use serde::de::Error as _;
|
||||||
|
|
||||||
let v = Vec::<T>::deserialize(deserializer)?;
|
let v = <Vec<T>>::deserialize(deserializer)?;
|
||||||
if v.is_empty() {
|
if v.is_empty() {
|
||||||
Err(D::Error::invalid_length(0, &"a positive integer"))
|
Err(D::Error::invalid_length(0, &"a non-empty sequence"))
|
||||||
} else {
|
} else {
|
||||||
Ok(v)
|
Ok(v)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
use std::future::Future;
|
||||||
|
use std::pin::Pin;
|
||||||
|
|
||||||
use crate::extensions::{ErrorLogger, ExtensionContext, ResolveInfo};
|
use crate::extensions::{ErrorLogger, ExtensionContext, ResolveInfo};
|
||||||
use crate::parser::types::Selection;
|
use crate::parser::types::Selection;
|
||||||
use crate::registry::MetaType;
|
use crate::registry::MetaType;
|
||||||
|
@ -5,9 +9,6 @@ use crate::{
|
||||||
Context, ContextSelectionSet, Name, OutputValueType, PathSegment, ServerError, ServerResult,
|
Context, ContextSelectionSet, Name, OutputValueType, PathSegment, ServerError, ServerResult,
|
||||||
Value,
|
Value,
|
||||||
};
|
};
|
||||||
use std::collections::BTreeMap;
|
|
||||||
use std::future::Future;
|
|
||||||
use std::pin::Pin;
|
|
||||||
|
|
||||||
/// Represents a GraphQL container object.
|
/// Represents a GraphQL container object.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::{CacheControl, Result, ServerError, Value};
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use crate::{CacheControl, Result, ServerError, Value};
|
||||||
|
|
||||||
/// Query response
|
/// Query response
|
||||||
#[derive(Debug, Default, Serialize)]
|
#[derive(Debug, Default, Serialize)]
|
||||||
pub struct Response {
|
pub struct Response {
|
||||||
|
|
|
@ -1,3 +1,13 @@
|
||||||
|
use std::any::Any;
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
use std::ops::Deref;
|
||||||
|
use std::sync::atomic::AtomicUsize;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
use futures::stream::{self, Stream, StreamExt};
|
||||||
|
use indexmap::map::IndexMap;
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::context::{Data, QueryEnvInner, ResolveId};
|
use crate::context::{Data, QueryEnvInner, ResolveId};
|
||||||
use crate::extensions::{ErrorLogger, ExtensionContext, ExtensionFactory, Extensions};
|
use crate::extensions::{ErrorLogger, ExtensionContext, ExtensionFactory, Extensions};
|
||||||
use crate::model::__DirectiveLocation;
|
use crate::model::__DirectiveLocation;
|
||||||
|
@ -12,14 +22,6 @@ use crate::{
|
||||||
BatchRequest, BatchResponse, CacheControl, ContextBase, ObjectType, QueryEnv, Request,
|
BatchRequest, BatchResponse, CacheControl, ContextBase, ObjectType, QueryEnv, Request,
|
||||||
Response, ServerError, SubscriptionType, Type, Value, ID,
|
Response, ServerError, SubscriptionType, Type, Value, ID,
|
||||||
};
|
};
|
||||||
use futures::stream::{self, Stream, StreamExt};
|
|
||||||
use indexmap::map::IndexMap;
|
|
||||||
use itertools::Itertools;
|
|
||||||
use std::any::Any;
|
|
||||||
use std::collections::BTreeMap;
|
|
||||||
use std::ops::Deref;
|
|
||||||
use std::sync::atomic::AtomicUsize;
|
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
/// Schema builder
|
/// Schema builder
|
||||||
pub struct SchemaBuilder<Query, Mutation, Subscription> {
|
pub struct SchemaBuilder<Query, Mutation, Subscription> {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
|
use std::pin::Pin;
|
||||||
|
|
||||||
|
use futures::{Stream, StreamExt};
|
||||||
|
|
||||||
use crate::parser::types::{Selection, TypeCondition};
|
use crate::parser::types::{Selection, TypeCondition};
|
||||||
use crate::{
|
use crate::{
|
||||||
Context, ContextSelectionSet, Name, PathSegment, ServerError, ServerResult, Type, Value,
|
Context, ContextSelectionSet, Name, PathSegment, ServerError, ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use futures::{Stream, StreamExt};
|
|
||||||
use std::pin::Pin;
|
|
||||||
|
|
||||||
/// A GraphQL subscription object
|
/// A GraphQL subscription object
|
||||||
pub trait SubscriptionType: Type {
|
pub trait SubscriptionType: Type {
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use futures::{Stream, StreamExt, TryStreamExt};
|
||||||
|
use indexmap::map::IndexMap;
|
||||||
|
|
||||||
use crate::connection::edge::Edge;
|
use crate::connection::edge::Edge;
|
||||||
use crate::connection::page_info::PageInfo;
|
use crate::connection::page_info::PageInfo;
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
|
@ -7,9 +12,6 @@ use crate::{
|
||||||
registry, Context, ContextSelectionSet, ObjectType, OutputValueType, Positioned, Result,
|
registry, Context, ContextSelectionSet, ObjectType, OutputValueType, Positioned, Result,
|
||||||
ServerResult, Type, Value,
|
ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use futures::{Stream, StreamExt, TryStreamExt};
|
|
||||||
use indexmap::map::IndexMap;
|
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
/// Connection type
|
/// Connection type
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use crate::ID;
|
|
||||||
use std::convert::Infallible;
|
use std::convert::Infallible;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::num::ParseIntError;
|
use std::num::ParseIntError;
|
||||||
|
|
||||||
|
use crate::ID;
|
||||||
|
|
||||||
/// Cursor type
|
/// Cursor type
|
||||||
///
|
///
|
||||||
/// A custom scalar that serializes as a string.
|
/// A custom scalar that serializes as a string.
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use indexmap::map::IndexMap;
|
||||||
|
|
||||||
use crate::connection::EmptyFields;
|
use crate::connection::EmptyFields;
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::resolver_utils::{resolve_container, ContainerType};
|
use crate::resolver_utils::{resolve_container, ContainerType};
|
||||||
|
@ -6,8 +10,6 @@ use crate::{
|
||||||
registry, Context, ContextSelectionSet, ObjectType, OutputValueType, Positioned, ServerResult,
|
registry, Context, ContextSelectionSet, ObjectType, OutputValueType, Positioned, ServerResult,
|
||||||
Type, Value,
|
Type, Value,
|
||||||
};
|
};
|
||||||
use indexmap::map::IndexMap;
|
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
/// The edge type output by the data source
|
/// The edge type output by the data source
|
||||||
pub struct Edge<C, T, E> {
|
pub struct Edge<C, T, E> {
|
||||||
|
|
|
@ -5,13 +5,14 @@ mod cursor;
|
||||||
mod edge;
|
mod edge;
|
||||||
mod page_info;
|
mod page_info;
|
||||||
|
|
||||||
|
use std::fmt::Display;
|
||||||
|
use std::future::Future;
|
||||||
|
|
||||||
use crate::{Result, SimpleObject};
|
use crate::{Result, SimpleObject};
|
||||||
pub use connection_type::Connection;
|
pub use connection_type::Connection;
|
||||||
pub use cursor::CursorType;
|
pub use cursor::CursorType;
|
||||||
pub use edge::Edge;
|
pub use edge::Edge;
|
||||||
use futures::Future;
|
|
||||||
pub use page_info::PageInfo;
|
pub use page_info::PageInfo;
|
||||||
use std::fmt::Display;
|
|
||||||
|
|
||||||
/// Empty additional fields
|
/// Empty additional fields
|
||||||
#[derive(SimpleObject)]
|
#[derive(SimpleObject)]
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::resolver_utils::ContainerType;
|
use crate::resolver_utils::ContainerType;
|
||||||
use crate::{
|
use crate::{
|
||||||
registry, Context, ContextSelectionSet, ObjectType, OutputValueType, Positioned, ServerError,
|
registry, Context, ContextSelectionSet, ObjectType, OutputValueType, Positioned, ServerError,
|
||||||
ServerResult, Type, Value,
|
ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
/// Empty mutation
|
/// Empty mutation
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
use crate::{registry, Context, ServerError, ServerResult, SubscriptionType, Type, Value};
|
|
||||||
use futures::{stream, Stream};
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
|
|
||||||
|
use futures::{stream, Stream};
|
||||||
|
|
||||||
|
use crate::{registry, Context, ServerError, ServerResult, SubscriptionType, Type, Value};
|
||||||
|
|
||||||
/// Empty subscription
|
/// Empty subscription
|
||||||
///
|
///
|
||||||
/// Only the parameters used to construct the Schema, representing an unconfigured subscription.
|
/// Only the parameters used to construct the Schema, representing an unconfigured subscription.
|
||||||
|
|
3
src/types/external/bson.rs
vendored
3
src/types/external/bson.rs
vendored
|
@ -1,10 +1,11 @@
|
||||||
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
|
||||||
use bson::oid::ObjectId;
|
use bson::oid::ObjectId;
|
||||||
#[cfg(feature = "chrono")]
|
#[cfg(feature = "chrono")]
|
||||||
use bson::DateTime as UtcDateTime;
|
use bson::DateTime as UtcDateTime;
|
||||||
#[cfg(feature = "chrono")]
|
#[cfg(feature = "chrono")]
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
|
||||||
|
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
||||||
|
|
||||||
#[Scalar(internal)]
|
#[Scalar(internal)]
|
||||||
impl ScalarType for ObjectId {
|
impl ScalarType for ObjectId {
|
||||||
fn parse(value: Value) -> InputValueResult<Self> {
|
fn parse(value: Value) -> InputValueResult<Self> {
|
||||||
|
|
7
src/types/external/chrono_tz.rs
vendored
7
src/types/external/chrono_tz.rs
vendored
|
@ -1,13 +1,12 @@
|
||||||
use crate::{InputValueError, InputValueResult, Result, ScalarType, Value};
|
|
||||||
use async_graphql_derive::Scalar;
|
|
||||||
use chrono_tz::Tz;
|
use chrono_tz::Tz;
|
||||||
use std::str::FromStr;
|
|
||||||
|
use crate::{InputValueError, InputValueResult, Result, ScalarType, Value, Scalar};
|
||||||
|
|
||||||
#[Scalar(internal, name = "TimeZone")]
|
#[Scalar(internal, name = "TimeZone")]
|
||||||
impl ScalarType for Tz {
|
impl ScalarType for Tz {
|
||||||
fn parse(value: Value) -> InputValueResult<Self> {
|
fn parse(value: Value) -> InputValueResult<Self> {
|
||||||
match value {
|
match value {
|
||||||
Value::String(s) => Ok(Tz::from_str(&s)?),
|
Value::String(s) => Ok(s.parse()?),
|
||||||
_ => Err(InputValueError::expected_type(value)),
|
_ => Err(InputValueError::expected_type(value)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
src/types/external/datetime.rs
vendored
3
src/types/external/datetime.rs
vendored
|
@ -1,6 +1,7 @@
|
||||||
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
|
||||||
use chrono::{DateTime, FixedOffset, Local, Utc};
|
use chrono::{DateTime, FixedOffset, Local, Utc};
|
||||||
|
|
||||||
|
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
||||||
|
|
||||||
/// Implement the DateTime<FixedOffset> scalar
|
/// Implement the DateTime<FixedOffset> scalar
|
||||||
///
|
///
|
||||||
/// The input/output is a string in RFC3339 format.
|
/// The input/output is a string in RFC3339 format.
|
||||||
|
|
3
src/types/external/json_object/btreemap.rs
vendored
3
src/types/external/json_object/btreemap.rs
vendored
|
@ -1,8 +1,9 @@
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
InputValueError, InputValueResult, InputValueType, Name, OutputValueType, Scalar, ScalarType,
|
InputValueError, InputValueResult, InputValueType, Name, OutputValueType, Scalar, ScalarType,
|
||||||
Value,
|
Value,
|
||||||
};
|
};
|
||||||
use std::collections::BTreeMap;
|
|
||||||
|
|
||||||
/// A scalar that can represent any JSON Object value.
|
/// A scalar that can represent any JSON Object value.
|
||||||
#[Scalar(internal, name = "JSONObject")]
|
#[Scalar(internal, name = "JSONObject")]
|
||||||
|
|
3
src/types/external/json_object/hashmap.rs
vendored
3
src/types/external/json_object/hashmap.rs
vendored
|
@ -1,8 +1,9 @@
|
||||||
|
use std::collections::{BTreeMap, HashMap};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
InputValueError, InputValueResult, InputValueType, Name, OutputValueType, Scalar, ScalarType,
|
InputValueError, InputValueResult, InputValueType, Name, OutputValueType, Scalar, ScalarType,
|
||||||
Value,
|
Value,
|
||||||
};
|
};
|
||||||
use std::collections::{BTreeMap, HashMap};
|
|
||||||
|
|
||||||
/// A scalar that can represent any JSON Object value.
|
/// A scalar that can represent any JSON Object value.
|
||||||
#[Scalar(internal, name = "JSONObject")]
|
#[Scalar(internal, name = "JSONObject")]
|
||||||
|
|
5
src/types/external/list/btree_set.rs
vendored
5
src/types/external/list/btree_set.rs
vendored
|
@ -1,11 +1,12 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
use std::collections::BTreeSet;
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::resolver_utils::resolve_list;
|
use crate::resolver_utils::resolve_list;
|
||||||
use crate::{
|
use crate::{
|
||||||
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
||||||
OutputValueType, Positioned, ServerResult, Type, Value,
|
OutputValueType, Positioned, ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::collections::BTreeSet;
|
|
||||||
|
|
||||||
impl<T: Type> Type for BTreeSet<T> {
|
impl<T: Type> Type for BTreeSet<T> {
|
||||||
fn type_name() -> Cow<'static, str> {
|
fn type_name() -> Cow<'static, str> {
|
||||||
|
|
9
src/types/external/list/hash_set.rs
vendored
9
src/types/external/list/hash_set.rs
vendored
|
@ -1,13 +1,14 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
use std::cmp::Eq;
|
||||||
|
use std::collections::HashSet;
|
||||||
|
use std::hash::Hash;
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::resolver_utils::resolve_list;
|
use crate::resolver_utils::resolve_list;
|
||||||
use crate::{
|
use crate::{
|
||||||
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
||||||
OutputValueType, Positioned, Result, ServerResult, Type, Value,
|
OutputValueType, Positioned, Result, ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::cmp::Eq;
|
|
||||||
use std::collections::HashSet;
|
|
||||||
use std::hash::Hash;
|
|
||||||
|
|
||||||
impl<T: Type> Type for HashSet<T> {
|
impl<T: Type> Type for HashSet<T> {
|
||||||
fn type_name() -> Cow<'static, str> {
|
fn type_name() -> Cow<'static, str> {
|
||||||
|
|
5
src/types/external/list/linked_list.rs
vendored
5
src/types/external/list/linked_list.rs
vendored
|
@ -1,11 +1,12 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
use std::collections::LinkedList;
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::resolver_utils::resolve_list;
|
use crate::resolver_utils::resolve_list;
|
||||||
use crate::{
|
use crate::{
|
||||||
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
||||||
OutputValueType, Positioned, ServerResult, Type, Value,
|
OutputValueType, Positioned, ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::collections::LinkedList;
|
|
||||||
|
|
||||||
impl<T: Type> Type for LinkedList<T> {
|
impl<T: Type> Type for LinkedList<T> {
|
||||||
fn type_name() -> Cow<'static, str> {
|
fn type_name() -> Cow<'static, str> {
|
||||||
|
|
3
src/types/external/list/slice.rs
vendored
3
src/types/external/list/slice.rs
vendored
|
@ -1,9 +1,10 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::resolver_utils::resolve_list;
|
use crate::resolver_utils::resolve_list;
|
||||||
use crate::{
|
use crate::{
|
||||||
registry, ContextSelectionSet, OutputValueType, Positioned, ServerResult, Type, Value,
|
registry, ContextSelectionSet, OutputValueType, Positioned, ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
impl<'a, T: Type + 'a> Type for &'a [T] {
|
impl<'a, T: Type + 'a> Type for &'a [T] {
|
||||||
fn type_name() -> Cow<'static, str> {
|
fn type_name() -> Cow<'static, str> {
|
||||||
|
|
3
src/types/external/list/vec.rs
vendored
3
src/types/external/list/vec.rs
vendored
|
@ -1,10 +1,11 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::resolver_utils::resolve_list;
|
use crate::resolver_utils::resolve_list;
|
||||||
use crate::{
|
use crate::{
|
||||||
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
||||||
OutputValueType, Positioned, Result, ServerResult, Type, Value,
|
OutputValueType, Positioned, Result, ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
impl<T: Type> Type for Vec<T> {
|
impl<T: Type> Type for Vec<T> {
|
||||||
fn type_name() -> Cow<'static, str> {
|
fn type_name() -> Cow<'static, str> {
|
||||||
|
|
5
src/types/external/list/vec_deque.rs
vendored
5
src/types/external/list/vec_deque.rs
vendored
|
@ -1,11 +1,12 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::resolver_utils::resolve_list;
|
use crate::resolver_utils::resolve_list;
|
||||||
use crate::{
|
use crate::{
|
||||||
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
||||||
OutputValueType, Positioned, ServerResult, Type, Value,
|
OutputValueType, Positioned, ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::collections::VecDeque;
|
|
||||||
|
|
||||||
impl<T: Type> Type for VecDeque<T> {
|
impl<T: Type> Type for VecDeque<T> {
|
||||||
fn type_name() -> Cow<'static, str> {
|
fn type_name() -> Cow<'static, str> {
|
||||||
|
|
3
src/types/external/naive_time.rs
vendored
3
src/types/external/naive_time.rs
vendored
|
@ -1,6 +1,7 @@
|
||||||
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
|
||||||
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
|
use chrono::{NaiveDate, NaiveDateTime, NaiveTime};
|
||||||
|
|
||||||
|
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
||||||
|
|
||||||
#[Scalar(internal)]
|
#[Scalar(internal)]
|
||||||
impl ScalarType for NaiveDate {
|
impl ScalarType for NaiveDate {
|
||||||
fn parse(value: Value) -> InputValueResult<Self> {
|
fn parse(value: Value) -> InputValueResult<Self> {
|
||||||
|
|
3
src/types/external/non_zero_integers.rs
vendored
3
src/types/external/non_zero_integers.rs
vendored
|
@ -1,8 +1,9 @@
|
||||||
use crate::{InputValueError, InputValueResult, Number, Scalar, ScalarType, Value};
|
|
||||||
use std::num::{
|
use std::num::{
|
||||||
NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8,
|
NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::{InputValueError, InputValueResult, Number, Scalar, ScalarType, Value};
|
||||||
|
|
||||||
/// The `Int` scalar type represents non-fractional whole numeric values.
|
/// The `Int` scalar type represents non-fractional whole numeric values.
|
||||||
#[Scalar(internal, name = "Int")]
|
#[Scalar(internal, name = "Int")]
|
||||||
impl ScalarType for NonZeroI8 {
|
impl ScalarType for NonZeroI8 {
|
||||||
|
|
3
src/types/external/optional.rs
vendored
3
src/types/external/optional.rs
vendored
|
@ -1,9 +1,10 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::{
|
use crate::{
|
||||||
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
registry, ContextSelectionSet, InputValueError, InputValueResult, InputValueType,
|
||||||
OutputValueType, Positioned, ServerResult, Type, Value,
|
OutputValueType, Positioned, ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
impl<T: Type> Type for Option<T> {
|
impl<T: Type> Type for Option<T> {
|
||||||
fn type_name() -> Cow<'static, str> {
|
fn type_name() -> Cow<'static, str> {
|
||||||
|
|
3
src/types/external/string.rs
vendored
3
src/types/external/string.rs
vendored
|
@ -1,9 +1,10 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::{
|
use crate::{
|
||||||
registry, ContextSelectionSet, InputValueError, InputValueResult, OutputValueType, Positioned,
|
registry, ContextSelectionSet, InputValueError, InputValueResult, OutputValueType, Positioned,
|
||||||
Scalar, ScalarType, ServerResult, Type, Value,
|
Scalar, ScalarType, ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
/// The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
|
/// The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
|
||||||
#[Scalar(internal)]
|
#[Scalar(internal)]
|
||||||
|
|
3
src/types/external/url.rs
vendored
3
src/types/external/url.rs
vendored
|
@ -1,6 +1,7 @@
|
||||||
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
||||||
|
|
||||||
#[Scalar(internal)]
|
#[Scalar(internal)]
|
||||||
impl ScalarType for Url {
|
impl ScalarType for Url {
|
||||||
fn parse(value: Value) -> InputValueResult<Self> {
|
fn parse(value: Value) -> InputValueResult<Self> {
|
||||||
|
|
3
src/types/external/uuid.rs
vendored
3
src/types/external/uuid.rs
vendored
|
@ -1,6 +1,7 @@
|
||||||
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
|
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
||||||
|
|
||||||
#[Scalar(internal, name = "UUID")]
|
#[Scalar(internal, name = "UUID")]
|
||||||
impl ScalarType for Uuid {
|
impl ScalarType for Uuid {
|
||||||
fn parse(value: Value) -> InputValueResult<Self> {
|
fn parse(value: Value) -> InputValueResult<Self> {
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
|
||||||
#[cfg(feature = "bson")]
|
|
||||||
use bson::oid::{self, ObjectId};
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::num::ParseIntError;
|
use std::num::ParseIntError;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
|
#[cfg(feature = "bson")]
|
||||||
|
use bson::oid::{self, ObjectId};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
||||||
|
|
||||||
/// ID scalar
|
/// ID scalar
|
||||||
///
|
///
|
||||||
/// The input is a `&str`, `String`, `usize` or `uuid::UUID`, and the output is a string.
|
/// The input is a `&str`, `String`, `usize` or `uuid::UUID`, and the output is a string.
|
||||||
|
@ -45,7 +47,7 @@ macro_rules! try_from_integers {
|
||||||
impl TryFrom<ID> for $ty {
|
impl TryFrom<ID> for $ty {
|
||||||
type Error = ParseIntError;
|
type Error = ParseIntError;
|
||||||
|
|
||||||
fn try_from(id: ID) -> std::result::Result<Self, Self::Error> {
|
fn try_from(id: ID) -> Result<Self, Self::Error> {
|
||||||
id.0.parse()
|
id.0.parse()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,7 +61,7 @@ try_from_integers!(i8, i16, i32, i64, i128, u8, u16, u32, u64, u128, isize, usiz
|
||||||
impl TryFrom<ID> for uuid::Uuid {
|
impl TryFrom<ID> for uuid::Uuid {
|
||||||
type Error = uuid::Error;
|
type Error = uuid::Error;
|
||||||
|
|
||||||
fn try_from(id: ID) -> std::result::Result<Self, Self::Error> {
|
fn try_from(id: ID) -> Result<Self, Self::Error> {
|
||||||
uuid::Uuid::parse_str(&id.0)
|
uuid::Uuid::parse_str(&id.0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
|
use serde::de::DeserializeOwned;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::registry::{MetaType, Registry};
|
use crate::registry::{MetaType, Registry};
|
||||||
use crate::{
|
use crate::{
|
||||||
from_value, to_value, ContextSelectionSet, InputValueResult, OutputValueType, Positioned,
|
from_value, to_value, ContextSelectionSet, InputValueResult, OutputValueType, Positioned,
|
||||||
Scalar, ScalarType, ServerResult, Type, Value,
|
Scalar, ScalarType, ServerResult, Type, Value,
|
||||||
};
|
};
|
||||||
use serde::de::DeserializeOwned;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::borrow::Cow;
|
|
||||||
use std::ops::{Deref, DerefMut};
|
|
||||||
|
|
||||||
/// A scalar that can represent any JSON value.
|
/// A scalar that can represent any JSON value.
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use crate::{registry, InputValueError, InputValueResult, InputValueType, Type, Value};
|
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
|
use crate::{registry, InputValueError, InputValueResult, InputValueType, Type, Value};
|
||||||
|
|
||||||
/// Similar to `Option`, but it has three states, `undefined`, `null` and `x`.
|
/// Similar to `Option`, but it has three states, `undefined`, `null` and `x`.
|
||||||
///
|
///
|
||||||
/// **Reference:** <https://spec.graphql.org/June2018/#sec-Null-Value>
|
/// **Reference:** <https://spec.graphql.org/June2018/#sec-Null-Value>
|
||||||
|
@ -132,7 +134,7 @@ impl<T: InputValueType> InputValueType for MaybeUndefined<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Serialize> Serialize for MaybeUndefined<T> {
|
impl<T: Serialize> Serialize for MaybeUndefined<T> {
|
||||||
fn serialize<S: Serializer>(&self, serializer: S) -> std::result::Result<S::Ok, S::Error> {
|
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||||
match self {
|
match self {
|
||||||
MaybeUndefined::Value(value) => value.serialize(serializer),
|
MaybeUndefined::Value(value) => value.serialize(serializer),
|
||||||
_ => serializer.serialize_none(),
|
_ => serializer.serialize_none(),
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use indexmap::IndexMap;
|
||||||
|
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::registry::{MetaType, Registry};
|
use crate::registry::{MetaType, Registry};
|
||||||
use crate::resolver_utils::resolve_container;
|
use crate::resolver_utils::resolve_container;
|
||||||
|
@ -5,8 +9,6 @@ use crate::{
|
||||||
CacheControl, ContainerType, Context, ContextSelectionSet, ObjectType, OutputValueType,
|
CacheControl, ContainerType, Context, ContextSelectionSet, ObjectType, OutputValueType,
|
||||||
Positioned, ServerResult, SimpleObject, Type, Value,
|
Positioned, ServerResult, SimpleObject, Type, Value,
|
||||||
};
|
};
|
||||||
use indexmap::IndexMap;
|
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
pub struct MergedObject<A, B>(pub A, pub B);
|
pub struct MergedObject<A, B>(pub A, pub B);
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
|
use indexmap::map::IndexMap;
|
||||||
|
|
||||||
use crate::model::{__Schema, __Type};
|
use crate::model::{__Schema, __Type};
|
||||||
use crate::parser::types::Field;
|
use crate::parser::types::Field;
|
||||||
use crate::resolver_utils::{resolve_container, ContainerType};
|
use crate::resolver_utils::{resolve_container, ContainerType};
|
||||||
|
@ -6,9 +10,6 @@ use crate::{
|
||||||
ServerError, ServerResult, SimpleObject, Type, Value,
|
ServerError, ServerResult, SimpleObject, Type, Value,
|
||||||
};
|
};
|
||||||
|
|
||||||
use indexmap::map::IndexMap;
|
|
||||||
use std::borrow::Cow;
|
|
||||||
|
|
||||||
/// Federation service
|
/// Federation service
|
||||||
#[derive(SimpleObject)]
|
#[derive(SimpleObject)]
|
||||||
#[graphql(internal, name = "_Service")]
|
#[graphql(internal, name = "_Service")]
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
|
||||||
use num_traits::Num;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use num_traits::Num;
|
||||||
|
|
||||||
|
use crate::{InputValueError, InputValueResult, Scalar, ScalarType, Value};
|
||||||
|
|
||||||
/// A numeric value represented by a string.
|
/// A numeric value represented by a string.
|
||||||
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, Serialize, Deserialize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
use crate::{registry, Context, InputValueError, InputValueResult, InputValueType, Type, Value};
|
|
||||||
use futures::AsyncRead;
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
|
|
||||||
|
use futures::AsyncRead;
|
||||||
|
|
||||||
|
use crate::{registry, Context, InputValueError, InputValueResult, InputValueType, Type, Value};
|
||||||
|
|
||||||
/// A file upload value.
|
/// A file upload value.
|
||||||
pub struct UploadValue {
|
pub struct UploadValue {
|
||||||
/// The name of the file.
|
/// The name of the file.
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use indexmap::map::IndexMap;
|
||||||
|
|
||||||
use crate::context::QueryPathNode;
|
use crate::context::QueryPathNode;
|
||||||
use crate::parser::types::{Directive, Field};
|
use crate::parser::types::{Directive, Field};
|
||||||
use crate::registry::MetaInputValue;
|
use crate::registry::MetaInputValue;
|
||||||
|
@ -5,7 +7,6 @@ use crate::validation::utils::is_valid_input_value;
|
||||||
use crate::validation::visitor::{Visitor, VisitorContext};
|
use crate::validation::visitor::{Visitor, VisitorContext};
|
||||||
use crate::{Name, Positioned, QueryPathSegment};
|
use crate::{Name, Positioned, QueryPathSegment};
|
||||||
use async_graphql_value::Value;
|
use async_graphql_value::Value;
|
||||||
use indexmap::map::IndexMap;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct ArgumentsOfCorrectType<'a> {
|
pub struct ArgumentsOfCorrectType<'a> {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
use indexmap::map::IndexMap;
|
||||||
|
|
||||||
use crate::parser::types::{Directive, Field};
|
use crate::parser::types::{Directive, Field};
|
||||||
use crate::registry::MetaInputValue;
|
use crate::registry::MetaInputValue;
|
||||||
use crate::validation::suggestion::make_suggestion;
|
use crate::validation::suggestion::make_suggestion;
|
||||||
use crate::validation::visitor::{Visitor, VisitorContext};
|
use crate::validation::visitor::{Visitor, VisitorContext};
|
||||||
use crate::{Name, Positioned};
|
use crate::{Name, Positioned};
|
||||||
use async_graphql_value::Value;
|
use async_graphql_value::Value;
|
||||||
use indexmap::map::IndexMap;
|
|
||||||
|
|
||||||
enum ArgsType<'a> {
|
enum ArgsType<'a> {
|
||||||
Directive(&'a str),
|
Directive(&'a str),
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use crate::parser::types::{ExecutableDocument, FragmentDefinition, FragmentSpread};
|
use crate::parser::types::{ExecutableDocument, FragmentDefinition, FragmentSpread};
|
||||||
use crate::validation::visitor::{RuleError, Visitor, VisitorContext};
|
use crate::validation::visitor::{RuleError, Visitor, VisitorContext};
|
||||||
use crate::{Name, Pos, Positioned};
|
use crate::{Name, Pos, Positioned};
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
|
|
||||||
struct CycleDetector<'a> {
|
struct CycleDetector<'a> {
|
||||||
visited: HashSet<&'a str>,
|
visited: HashSet<&'a str>,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use crate::parser::types::{
|
use crate::parser::types::{
|
||||||
ExecutableDocument, FragmentDefinition, FragmentSpread, OperationDefinition, VariableDefinition,
|
ExecutableDocument, FragmentDefinition, FragmentSpread, OperationDefinition, VariableDefinition,
|
||||||
};
|
};
|
||||||
|
@ -5,7 +7,6 @@ use crate::validation::utils::{referenced_variables, Scope};
|
||||||
use crate::validation::visitor::{Visitor, VisitorContext};
|
use crate::validation::visitor::{Visitor, VisitorContext};
|
||||||
use crate::{Name, Pos, Positioned};
|
use crate::{Name, Pos, Positioned};
|
||||||
use async_graphql_value::Value;
|
use async_graphql_value::Value;
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct NoUndefinedVariables<'a> {
|
pub struct NoUndefinedVariables<'a> {
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use crate::parser::types::{
|
use crate::parser::types::{
|
||||||
ExecutableDocument, FragmentDefinition, FragmentSpread, OperationDefinition,
|
ExecutableDocument, FragmentDefinition, FragmentSpread, OperationDefinition,
|
||||||
};
|
};
|
||||||
use crate::validation::utils::Scope;
|
use crate::validation::utils::Scope;
|
||||||
use crate::validation::visitor::{Visitor, VisitorContext};
|
use crate::validation::visitor::{Visitor, VisitorContext};
|
||||||
use crate::{Name, Pos, Positioned};
|
use crate::{Name, Pos, Positioned};
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct NoUnusedFragments<'a> {
|
pub struct NoUnusedFragments<'a> {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use crate::parser::types::{
|
use crate::parser::types::{
|
||||||
ExecutableDocument, FragmentDefinition, FragmentSpread, OperationDefinition, VariableDefinition,
|
ExecutableDocument, FragmentDefinition, FragmentSpread, OperationDefinition, VariableDefinition,
|
||||||
};
|
};
|
||||||
|
@ -5,7 +7,6 @@ use crate::validation::utils::{referenced_variables, Scope};
|
||||||
use crate::validation::visitor::{Visitor, VisitorContext};
|
use crate::validation::visitor::{Visitor, VisitorContext};
|
||||||
use crate::{Name, Pos, Positioned};
|
use crate::{Name, Pos, Positioned};
|
||||||
use async_graphql_value::Value;
|
use async_graphql_value::Value;
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct NoUnusedVariables<'a> {
|
pub struct NoUnusedVariables<'a> {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::parser::types::{Field, Selection, SelectionSet};
|
use crate::parser::types::{Field, Selection, SelectionSet};
|
||||||
use crate::validation::visitor::{Visitor, VisitorContext};
|
use crate::validation::visitor::{Visitor, VisitorContext};
|
||||||
use crate::Positioned;
|
use crate::Positioned;
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct OverlappingFieldsCanBeMerged;
|
pub struct OverlappingFieldsCanBeMerged;
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::parser::types::{ExecutableDocument, FragmentSpread, InlineFragment, TypeCondition};
|
use crate::parser::types::{ExecutableDocument, FragmentSpread, InlineFragment, TypeCondition};
|
||||||
use crate::validation::visitor::{Visitor, VisitorContext};
|
use crate::validation::visitor::{Visitor, VisitorContext};
|
||||||
use crate::Positioned;
|
use crate::Positioned;
|
||||||
use std::collections::HashMap;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct PossibleFragmentSpreads<'a> {
|
pub struct PossibleFragmentSpreads<'a> {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use crate::parser::types::{Directive, Field};
|
use crate::parser::types::{Directive, Field};
|
||||||
use crate::validation::visitor::{Visitor, VisitorContext};
|
use crate::validation::visitor::{Visitor, VisitorContext};
|
||||||
use crate::{Name, Positioned};
|
use crate::{Name, Positioned};
|
||||||
use async_graphql_value::Value;
|
use async_graphql_value::Value;
|
||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct UniqueArgumentNames<'a> {
|
pub struct UniqueArgumentNames<'a> {
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use crate::parser::types::{OperationDefinition, VariableDefinition};
|
use crate::parser::types::{OperationDefinition, VariableDefinition};
|
||||||
use crate::validation::visitor::{Visitor, VisitorContext};
|
use crate::validation::visitor::{Visitor, VisitorContext};
|
||||||
use crate::{Name, Positioned};
|
use crate::{Name, Positioned};
|
||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct UniqueVariableNames<'a> {
|
pub struct UniqueVariableNames<'a> {
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use crate::parser::types::{
|
use crate::parser::types::{
|
||||||
ExecutableDocument, FragmentDefinition, FragmentSpread, OperationDefinition, VariableDefinition,
|
ExecutableDocument, FragmentDefinition, FragmentSpread, OperationDefinition, VariableDefinition,
|
||||||
};
|
};
|
||||||
|
@ -6,7 +8,6 @@ use crate::validation::utils::Scope;
|
||||||
use crate::validation::visitor::{Visitor, VisitorContext};
|
use crate::validation::visitor::{Visitor, VisitorContext};
|
||||||
use crate::{Name, Pos, Positioned};
|
use crate::{Name, Pos, Positioned};
|
||||||
use async_graphql_value::Value;
|
use async_graphql_value::Value;
|
||||||
use std::collections::{HashMap, HashSet};
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct VariableInAllowedPosition<'a> {
|
pub struct VariableInAllowedPosition<'a> {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use itertools::Itertools;
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use itertools::Itertools;
|
||||||
|
|
||||||
fn levenshtein_distance(s1: &str, s2: &str) -> usize {
|
fn levenshtein_distance(s1: &str, s2: &str) -> usize {
|
||||||
let mut column = (0..=s1.len()).collect_vec();
|
let mut column = (0..=s1.len()).collect_vec();
|
||||||
for (x, rx) in s2.bytes().enumerate() {
|
for (x, rx) in s2.bytes().enumerate() {
|
||||||
|
|
|
@ -2,10 +2,11 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(unreachable_code)]
|
#![allow(unreachable_code)]
|
||||||
|
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::parser::types::ExecutableDocument;
|
use crate::parser::types::ExecutableDocument;
|
||||||
use crate::validation::visitor::{visit, RuleError, Visitor, VisitorContext};
|
use crate::validation::visitor::{visit, RuleError, Visitor, VisitorContext};
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
|
|
||||||
#[derive(InputObject)]
|
#[derive(InputObject)]
|
||||||
#[graphql(internal)]
|
#[graphql(internal)]
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use crate::context::QueryPathNode;
|
use crate::context::QueryPathNode;
|
||||||
use crate::{registry, QueryPathSegment};
|
use crate::{registry, QueryPathSegment};
|
||||||
use async_graphql_value::{ConstValue, Value};
|
use async_graphql_value::{ConstValue, Value};
|
||||||
use std::collections::HashSet;
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum Scope<'a> {
|
pub enum Scope<'a> {
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::fmt::{self, Display, Formatter};
|
||||||
|
|
||||||
use crate::parser::types::{
|
use crate::parser::types::{
|
||||||
Directive, ExecutableDocument, Field, FragmentDefinition, FragmentSpread, InlineFragment,
|
Directive, ExecutableDocument, Field, FragmentDefinition, FragmentSpread, InlineFragment,
|
||||||
OperationDefinition, OperationType, Selection, SelectionSet, TypeCondition, VariableDefinition,
|
OperationDefinition, OperationType, Selection, SelectionSet, TypeCondition, VariableDefinition,
|
||||||
|
@ -5,8 +8,6 @@ use crate::parser::types::{
|
||||||
use crate::registry::{self, MetaType, MetaTypeName};
|
use crate::registry::{self, MetaType, MetaTypeName};
|
||||||
use crate::{Name, Pos, Positioned, ServerError, Variables};
|
use crate::{Name, Pos, Positioned, ServerError, Variables};
|
||||||
use async_graphql_value::Value;
|
use async_graphql_value::Value;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::fmt::{self, Display, Formatter};
|
|
||||||
|
|
||||||
pub(crate) struct VisitorContext<'a> {
|
pub(crate) struct VisitorContext<'a> {
|
||||||
pub(crate) registry: &'a registry::Registry,
|
pub(crate) registry: &'a registry::Registry,
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
use crate::validators::InputValueValidator;
|
|
||||||
use crate::Value;
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
|
use crate::validators::InputValueValidator;
|
||||||
|
use crate::Value;
|
||||||
|
|
||||||
/// String minimum length validator
|
/// String minimum length validator
|
||||||
pub struct StringMinLength {
|
pub struct StringMinLength {
|
||||||
/// Must be greater than or equal to this value.
|
/// Must be greater than or equal to this value.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user