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 slice;
use crate::{Context, FieldResult, ObjectType, OutputValueType};
use crate::{Context, FieldResult};
pub use connection_type::Connection;
pub use cursor::CursorType;
pub use edge::Edge;
@ -115,19 +115,19 @@ pub trait DataSource {
type CursorType: CursorType + Send + Sync;
/// Record type
type NodeType: OutputValueType + Send;
type NodeType;
/// Additional fields for connection
///
/// 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
///
/// 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.
async fn query(

View File

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