@@ -22,7 +22,7 @@ use crate::{
22
22
} ,
23
23
model:: { RootNode , SchemaType , TypeType } ,
24
24
} ,
25
- types:: { base:: GraphQLType , name:: Name } ,
25
+ types:: { base:: { GraphQLType , GraphQLValue } , name:: Name , async_await :: GraphQLValueAsync } ,
26
26
value:: { DefaultScalarValue , ParseScalarValue , ScalarValue , Value } ,
27
27
GraphQLError ,
28
28
} ;
@@ -244,7 +244,7 @@ impl<S> IntoFieldError<S> for FieldError<S> {
244
244
#[ doc( hidden) ]
245
245
pub trait IntoResolvable < ' a , S , T , C >
246
246
where
247
- T : GraphQLType < S > ,
247
+ T : GraphQLValue < S > ,
248
248
S : ScalarValue ,
249
249
{
250
250
#[ doc( hidden) ]
@@ -253,7 +253,7 @@ where
253
253
254
254
impl < ' a , S , T , C > IntoResolvable < ' a , S , T , C > for T
255
255
where
256
- T : GraphQLType < S > ,
256
+ T : GraphQLValue < S > ,
257
257
S : ScalarValue ,
258
258
T :: Context : FromContext < C > ,
259
259
{
@@ -265,7 +265,7 @@ where
265
265
impl < ' a , S , T , C , E : IntoFieldError < S > > IntoResolvable < ' a , S , T , C > for Result < T , E >
266
266
where
267
267
S : ScalarValue ,
268
- T : GraphQLType < S > ,
268
+ T : GraphQLValue < S > ,
269
269
T :: Context : FromContext < C > ,
270
270
{
271
271
fn into ( self , ctx : & ' a C ) -> FieldResult < Option < ( & ' a T :: Context , T ) > , S > {
@@ -277,7 +277,7 @@ where
277
277
impl < ' a , S , T , C > IntoResolvable < ' a , S , T , C > for ( & ' a T :: Context , T )
278
278
where
279
279
S : ScalarValue ,
280
- T : GraphQLType < S > ,
280
+ T : GraphQLValue < S > ,
281
281
{
282
282
fn into ( self , _: & ' a C ) -> FieldResult < Option < ( & ' a T :: Context , T ) > , S > {
283
283
Ok ( Some ( self ) )
@@ -287,7 +287,7 @@ where
287
287
impl < ' a , S , T , C > IntoResolvable < ' a , S , Option < T > , C > for Option < ( & ' a T :: Context , T ) >
288
288
where
289
289
S : ScalarValue ,
290
- T : GraphQLType < S > ,
290
+ T : GraphQLValue < S > ,
291
291
{
292
292
fn into ( self , _: & ' a C ) -> FieldResult < Option < ( & ' a T :: Context , Option < T > ) > , S > {
293
293
Ok ( self . map ( |( ctx, v) | ( ctx, Some ( v) ) ) )
@@ -297,7 +297,7 @@ where
297
297
impl < ' a , S , T , C > IntoResolvable < ' a , S , T , C > for FieldResult < ( & ' a T :: Context , T ) , S >
298
298
where
299
299
S : ScalarValue ,
300
- T : GraphQLType < S > ,
300
+ T : GraphQLValue < S > ,
301
301
{
302
302
fn into ( self , _: & ' a C ) -> FieldResult < Option < ( & ' a T :: Context , T ) > , S > {
303
303
self . map ( Some )
@@ -308,7 +308,7 @@ impl<'a, S, T, C> IntoResolvable<'a, S, Option<T>, C>
308
308
for FieldResult < Option < ( & ' a T :: Context , T ) > , S >
309
309
where
310
310
S : ScalarValue ,
311
- T : GraphQLType < S > ,
311
+ T : GraphQLValue < S > ,
312
312
{
313
313
fn into ( self , _: & ' a C ) -> FieldResult < Option < ( & ' a T :: Context , Option < T > ) > , S > {
314
314
self . map ( |o| o. map ( |( ctx, v) | ( ctx, Some ( v) ) ) )
@@ -405,7 +405,7 @@ where
405
405
pub fn resolve_with_ctx < NewCtxT , T > ( & self , info : & T :: TypeInfo , value : & T ) -> ExecutionResult < S >
406
406
where
407
407
NewCtxT : FromContext < CtxT > ,
408
- T : GraphQLType < S , Context = NewCtxT > + ?Sized ,
408
+ T : GraphQLValue < S , Context = NewCtxT > + ?Sized ,
409
409
{
410
410
self . replaced_context ( <NewCtxT as FromContext < CtxT > >:: from ( self . context ) )
411
411
. resolve ( info, value)
@@ -414,15 +414,15 @@ where
414
414
/// Resolve a single arbitrary value into an `ExecutionResult`
415
415
pub fn resolve < T > ( & self , info : & T :: TypeInfo , value : & T ) -> ExecutionResult < S >
416
416
where
417
- T : GraphQLType < S , Context = CtxT > + ?Sized ,
417
+ T : GraphQLValue < S , Context = CtxT > + ?Sized ,
418
418
{
419
419
value. resolve ( info, self . current_selection_set , self )
420
420
}
421
421
422
422
/// Resolve a single arbitrary value into an `ExecutionResult`
423
423
pub async fn resolve_async < T > ( & self , info : & T :: TypeInfo , value : & T ) -> ExecutionResult < S >
424
424
where
425
- T : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync + ?Sized ,
425
+ T : GraphQLValueAsync < S , Context = CtxT > + Send + Sync + ?Sized ,
426
426
T :: TypeInfo : Send + Sync ,
427
427
CtxT : Send + Sync ,
428
428
S : Send + Sync ,
@@ -439,7 +439,7 @@ where
439
439
value : & T ,
440
440
) -> ExecutionResult < S >
441
441
where
442
- T : crate :: GraphQLTypeAsync < S , Context = NewCtxT > + Send + Sync ,
442
+ T : GraphQLValueAsync < S , Context = NewCtxT > + Send + Sync ,
443
443
T :: TypeInfo : Send + Sync ,
444
444
S : Send + Sync ,
445
445
NewCtxT : FromContext < CtxT > + Send + Sync ,
@@ -453,23 +453,20 @@ where
453
453
/// If the field fails to resolve, `null` will be returned.
454
454
pub fn resolve_into_value < T > ( & self , info : & T :: TypeInfo , value : & T ) -> Value < S >
455
455
where
456
- T : GraphQLType < S , Context = CtxT > ,
456
+ T : GraphQLValue < S , Context = CtxT > ,
457
457
{
458
- match self . resolve ( info, value) {
459
- Ok ( v) => v,
460
- Err ( e) => {
461
- self . push_error ( e) ;
462
- Value :: null ( )
463
- }
464
- }
458
+ self . resolve ( info, value) . unwrap_or_else ( |e| {
459
+ self . push_error ( e) ;
460
+ Value :: null ( )
461
+ } )
465
462
}
466
463
467
464
/// Resolve a single arbitrary value into a return value
468
465
///
469
466
/// If the field fails to resolve, `null` will be returned.
470
467
pub async fn resolve_into_value_async < T > ( & self , info : & T :: TypeInfo , value : & T ) -> Value < S >
471
468
where
472
- T : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync + ?Sized ,
469
+ T : GraphQLValueAsync < S , Context = CtxT > + Send + Sync + ?Sized ,
473
470
T :: TypeInfo : Send + Sync ,
474
471
CtxT : Send + Sync ,
475
472
S : Send + Sync ,
@@ -757,9 +754,9 @@ pub fn execute_validated_query<'a, 'b, QueryT, MutationT, SubscriptionT, CtxT, S
757
754
) -> Result < ( Value < S > , Vec < ExecutionError < S > > ) , GraphQLError < ' a > >
758
755
where
759
756
S : ScalarValue ,
760
- QueryT : GraphQLType < S , Context = CtxT > ,
761
- MutationT : GraphQLType < S , Context = CtxT > ,
762
- SubscriptionT : GraphQLType < S , Context = CtxT > ,
757
+ QueryT : GraphQLValue < S , Context = CtxT > ,
758
+ MutationT : GraphQLValue < S , Context = CtxT > ,
759
+ SubscriptionT : GraphQLValue < S , Context = CtxT > ,
763
760
{
764
761
if operation. item . operation_type == OperationType :: Subscription {
765
762
return Err ( GraphQLError :: IsSubscription ) ;
@@ -851,11 +848,11 @@ pub async fn execute_validated_query_async<'a, 'b, QueryT, MutationT, Subscripti
851
848
) -> Result < ( Value < S > , Vec < ExecutionError < S > > ) , GraphQLError < ' a > >
852
849
where
853
850
S : ScalarValue + Send + Sync ,
854
- QueryT : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
851
+ QueryT : GraphQLValueAsync < S , Context = CtxT > + Send + Sync ,
855
852
QueryT :: TypeInfo : Send + Sync ,
856
- MutationT : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
853
+ MutationT : GraphQLValueAsync < S , Context = CtxT > + Send + Sync ,
857
854
MutationT :: TypeInfo : Send + Sync ,
858
- SubscriptionT : GraphQLType < S , Context = CtxT > + Send + Sync ,
855
+ SubscriptionT : GraphQLValue < S , Context = CtxT > + Send + Sync ,
859
856
SubscriptionT :: TypeInfo : Send + Sync ,
860
857
CtxT : Send + Sync ,
861
858
{
@@ -998,9 +995,9 @@ where
998
995
' d : ' r ,
999
996
' op : ' d ,
1000
997
S : ScalarValue + Send + Sync ,
1001
- QueryT : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
998
+ QueryT : GraphQLValueAsync < S , Context = CtxT > + Send + Sync ,
1002
999
QueryT :: TypeInfo : Send + Sync ,
1003
- MutationT : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
1000
+ MutationT : GraphQLValueAsync < S , Context = CtxT > + Send + Sync ,
1004
1001
MutationT :: TypeInfo : Send + Sync ,
1005
1002
SubscriptionT : crate :: GraphQLSubscriptionType < S , Context = CtxT > + Send + Sync ,
1006
1003
SubscriptionT :: TypeInfo : Send + Sync ,
0 commit comments