Remove premature generic constraints of DataSource type.

This commit is contained in:
Sunli 2020-05-29 12:42:58 +08:00
parent 1780562043
commit e3577250eb
2 changed files with 6 additions and 9 deletions

View File

@ -6,7 +6,7 @@ mod edge;
mod page_info; mod page_info;
mod slice; mod slice;
use crate::{Context, FieldResult, ObjectType, OutputValueType}; use crate::{Context, FieldResult};
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;
@ -115,19 +115,19 @@ pub trait DataSource {
type CursorType: CursorType + Send + Sync; type CursorType: CursorType + Send + Sync;
/// Record type /// Record type
type NodeType: OutputValueType + Send; type NodeType;
/// Additional fields for connection /// Additional fields for connection
/// ///
/// Is a type that implements `ObjectType` and can be defined by the procedure macro `#[Object]` or `#[SimpleObject]`. /// Is a type that implements `ObjectType` and can be defined by the procedure macro `#[Object]` or `#[SimpleObject]`.
/// ///
type ConnectionFieldsType: ObjectType + Send; type ConnectionFieldsType;
/// Additional fields for edge /// Additional fields for edge
/// ///
/// Is a type that implements `ObjectType` and can be defined by the procedure macro `#[Object]` or `#[SimpleObject]`. /// Is a type that implements `ObjectType` and can be defined by the procedure macro `#[Object]` or `#[SimpleObject]`.
/// ///
type EdgeFieldsType: ObjectType + Send; type EdgeFieldsType;
/// Parses the parameters and executes the query. /// Parses the parameters and executes the query.
async fn query( async fn query(

View File

@ -1,12 +1,9 @@
use crate::connection::{Connection, DataSource, Edge, EmptyFields}; use crate::connection::{Connection, DataSource, Edge, EmptyFields};
use crate::{Context, FieldResult, OutputValueType}; use crate::{Context, FieldResult};
use async_graphql_derive::DataSource; use async_graphql_derive::DataSource;
#[DataSource(internal)] #[DataSource(internal)]
impl<'a, T> DataSource for &'a [T] impl<'a, T: Send + Sync> DataSource for &'a [T] {
where
T: OutputValueType + Send + Sync + 'a,
{
type CursorType = usize; type CursorType = usize;
type NodeType = &'a T; type NodeType = &'a T;
type ConnectionFieldsType = EmptyFields; type ConnectionFieldsType = EmptyFields;