@@ -22,7 +22,12 @@ use crate::{
22
22
} ,
23
23
model:: { RootNode , SchemaType , TypeType } ,
24
24
} ,
25
- types:: { base:: GraphQLType , name:: Name } ,
25
+ types:: {
26
+ async_await:: { GraphQLTypeAsync , GraphQLValueAsync } ,
27
+ base:: { GraphQLType , GraphQLValue } ,
28
+ name:: Name ,
29
+ subscriptions:: { GraphQLSubscriptionType , GraphQLSubscriptionValue } ,
30
+ } ,
26
31
value:: { DefaultScalarValue , ParseScalarValue , ScalarValue , Value } ,
27
32
GraphQLError ,
28
33
} ;
@@ -244,7 +249,7 @@ impl<S> IntoFieldError<S> for FieldError<S> {
244
249
#[ doc( hidden) ]
245
250
pub trait IntoResolvable < ' a , S , T , C >
246
251
where
247
- T : GraphQLType < S > ,
252
+ T : GraphQLValue < S > ,
248
253
S : ScalarValue ,
249
254
{
250
255
#[ doc( hidden) ]
@@ -253,7 +258,7 @@ where
253
258
254
259
impl < ' a , S , T , C > IntoResolvable < ' a , S , T , C > for T
255
260
where
256
- T : GraphQLType < S > ,
261
+ T : GraphQLValue < S > ,
257
262
S : ScalarValue ,
258
263
T :: Context : FromContext < C > ,
259
264
{
@@ -265,7 +270,7 @@ where
265
270
impl < ' a , S , T , C , E : IntoFieldError < S > > IntoResolvable < ' a , S , T , C > for Result < T , E >
266
271
where
267
272
S : ScalarValue ,
268
- T : GraphQLType < S > ,
273
+ T : GraphQLValue < S > ,
269
274
T :: Context : FromContext < C > ,
270
275
{
271
276
fn into ( self , ctx : & ' a C ) -> FieldResult < Option < ( & ' a T :: Context , T ) > , S > {
@@ -277,7 +282,7 @@ where
277
282
impl < ' a , S , T , C > IntoResolvable < ' a , S , T , C > for ( & ' a T :: Context , T )
278
283
where
279
284
S : ScalarValue ,
280
- T : GraphQLType < S > ,
285
+ T : GraphQLValue < S > ,
281
286
{
282
287
fn into ( self , _: & ' a C ) -> FieldResult < Option < ( & ' a T :: Context , T ) > , S > {
283
288
Ok ( Some ( self ) )
@@ -287,7 +292,7 @@ where
287
292
impl < ' a , S , T , C > IntoResolvable < ' a , S , Option < T > , C > for Option < ( & ' a T :: Context , T ) >
288
293
where
289
294
S : ScalarValue ,
290
- T : GraphQLType < S > ,
295
+ T : GraphQLValue < S > ,
291
296
{
292
297
fn into ( self , _: & ' a C ) -> FieldResult < Option < ( & ' a T :: Context , Option < T > ) > , S > {
293
298
Ok ( self . map ( |( ctx, v) | ( ctx, Some ( v) ) ) )
@@ -297,7 +302,7 @@ where
297
302
impl < ' a , S , T , C > IntoResolvable < ' a , S , T , C > for FieldResult < ( & ' a T :: Context , T ) , S >
298
303
where
299
304
S : ScalarValue ,
300
- T : GraphQLType < S > ,
305
+ T : GraphQLValue < S > ,
301
306
{
302
307
fn into ( self , _: & ' a C ) -> FieldResult < Option < ( & ' a T :: Context , T ) > , S > {
303
308
self . map ( Some )
@@ -308,7 +313,7 @@ impl<'a, S, T, C> IntoResolvable<'a, S, Option<T>, C>
308
313
for FieldResult < Option < ( & ' a T :: Context , T ) > , S >
309
314
where
310
315
S : ScalarValue ,
311
- T : GraphQLType < S > ,
316
+ T : GraphQLValue < S > ,
312
317
{
313
318
fn into ( self , _: & ' a C ) -> FieldResult < Option < ( & ' a T :: Context , Option < T > ) > , S > {
314
319
self . map ( |o| o. map ( |( ctx, v) | ( ctx, Some ( v) ) ) )
@@ -369,7 +374,7 @@ where
369
374
' i : ' res ,
370
375
' v : ' res ,
371
376
' a : ' res ,
372
- T : crate :: GraphQLSubscriptionType < S , Context = CtxT > + Send + Sync ,
377
+ T : GraphQLSubscriptionValue < S , Context = CtxT > + Send + Sync ,
373
378
T :: TypeInfo : Send + Sync ,
374
379
CtxT : Send + Sync ,
375
380
S : Send + Sync ,
@@ -393,7 +398,7 @@ where
393
398
where
394
399
' t : ' res ,
395
400
' a : ' res ,
396
- T : crate :: GraphQLSubscriptionType < S , Context = CtxT > ,
401
+ T : GraphQLSubscriptionValue < S , Context = CtxT > ,
397
402
T :: TypeInfo : Send + Sync ,
398
403
CtxT : Send + Sync ,
399
404
S : Send + Sync ,
@@ -405,7 +410,7 @@ where
405
410
pub fn resolve_with_ctx < NewCtxT , T > ( & self , info : & T :: TypeInfo , value : & T ) -> ExecutionResult < S >
406
411
where
407
412
NewCtxT : FromContext < CtxT > ,
408
- T : GraphQLType < S , Context = NewCtxT > + ?Sized ,
413
+ T : GraphQLValue < S , Context = NewCtxT > + ?Sized ,
409
414
{
410
415
self . replaced_context ( <NewCtxT as FromContext < CtxT > >:: from ( self . context ) )
411
416
. resolve ( info, value)
@@ -414,15 +419,15 @@ where
414
419
/// Resolve a single arbitrary value into an `ExecutionResult`
415
420
pub fn resolve < T > ( & self , info : & T :: TypeInfo , value : & T ) -> ExecutionResult < S >
416
421
where
417
- T : GraphQLType < S , Context = CtxT > + ?Sized ,
422
+ T : GraphQLValue < S , Context = CtxT > + ?Sized ,
418
423
{
419
424
value. resolve ( info, self . current_selection_set , self )
420
425
}
421
426
422
427
/// Resolve a single arbitrary value into an `ExecutionResult`
423
428
pub async fn resolve_async < T > ( & self , info : & T :: TypeInfo , value : & T ) -> ExecutionResult < S >
424
429
where
425
- T : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync + ?Sized ,
430
+ T : GraphQLValueAsync < S , Context = CtxT > + Send + Sync + ?Sized ,
426
431
T :: TypeInfo : Send + Sync ,
427
432
CtxT : Send + Sync ,
428
433
S : Send + Sync ,
@@ -439,7 +444,7 @@ where
439
444
value : & T ,
440
445
) -> ExecutionResult < S >
441
446
where
442
- T : crate :: GraphQLTypeAsync < S , Context = NewCtxT > + Send + Sync ,
447
+ T : GraphQLValueAsync < S , Context = NewCtxT > + Send + Sync ,
443
448
T :: TypeInfo : Send + Sync ,
444
449
S : Send + Sync ,
445
450
NewCtxT : FromContext < CtxT > + Send + Sync ,
@@ -453,23 +458,20 @@ where
453
458
/// If the field fails to resolve, `null` will be returned.
454
459
pub fn resolve_into_value < T > ( & self , info : & T :: TypeInfo , value : & T ) -> Value < S >
455
460
where
456
- T : GraphQLType < S , Context = CtxT > ,
461
+ T : GraphQLValue < S , Context = CtxT > ,
457
462
{
458
- match self . resolve ( info, value) {
459
- Ok ( v) => v,
460
- Err ( e) => {
461
- self . push_error ( e) ;
462
- Value :: null ( )
463
- }
464
- }
463
+ self . resolve ( info, value) . unwrap_or_else ( |e| {
464
+ self . push_error ( e) ;
465
+ Value :: null ( )
466
+ } )
465
467
}
466
468
467
469
/// Resolve a single arbitrary value into a return value
468
470
///
469
471
/// If the field fails to resolve, `null` will be returned.
470
472
pub async fn resolve_into_value_async < T > ( & self , info : & T :: TypeInfo , value : & T ) -> Value < S >
471
473
where
472
- T : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync + ?Sized ,
474
+ T : GraphQLValueAsync < S , Context = CtxT > + Send + Sync + ?Sized ,
473
475
T :: TypeInfo : Send + Sync ,
474
476
CtxT : Send + Sync ,
475
477
S : Send + Sync ,
@@ -851,9 +853,9 @@ pub async fn execute_validated_query_async<'a, 'b, QueryT, MutationT, Subscripti
851
853
) -> Result < ( Value < S > , Vec < ExecutionError < S > > ) , GraphQLError < ' a > >
852
854
where
853
855
S : ScalarValue + Send + Sync ,
854
- QueryT : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
856
+ QueryT : GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
855
857
QueryT :: TypeInfo : Send + Sync ,
856
- MutationT : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
858
+ MutationT : GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
857
859
MutationT :: TypeInfo : Send + Sync ,
858
860
SubscriptionT : GraphQLType < S , Context = CtxT > + Send + Sync ,
859
861
SubscriptionT :: TypeInfo : Send + Sync ,
@@ -998,11 +1000,11 @@ where
998
1000
' d : ' r ,
999
1001
' op : ' d ,
1000
1002
S : ScalarValue + Send + Sync ,
1001
- QueryT : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
1003
+ QueryT : GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
1002
1004
QueryT :: TypeInfo : Send + Sync ,
1003
- MutationT : crate :: GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
1005
+ MutationT : GraphQLTypeAsync < S , Context = CtxT > + Send + Sync ,
1004
1006
MutationT :: TypeInfo : Send + Sync ,
1005
- SubscriptionT : crate :: GraphQLSubscriptionType < S , Context = CtxT > + Send + Sync ,
1007
+ SubscriptionT : GraphQLSubscriptionType < S , Context = CtxT > + Send + Sync ,
1006
1008
SubscriptionT :: TypeInfo : Send + Sync ,
1007
1009
CtxT : Send + Sync + ' r ,
1008
1010
{
0 commit comments