You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/FSharp.Data.GraphQL.Server/Execution.fs
+95-91Lines changed: 95 additions & 91 deletions
Original file line number
Diff line number
Diff line change
@@ -323,102 +323,106 @@ let private propagateError name err = asyncVal { return ResolverError{ Name = na
323
323
/// Builds the result tree for a given query
324
324
let recprivatebuildResolverTree(returnDef:OutputDef)(ctx:ResolveFieldContext)(fieldExecuteMap:FieldExecuteMap)(value:obj option):AsyncVal<ResolverTree>=
325
325
letname= ctx.ExecutionInfo.Identifier
326
-
match returnDef with
327
-
| Object objdef ->
328
-
match ctx.ExecutionInfo.Kind with
329
-
| SelectFields fields ->
326
+
match ctx.ExecutionInfo.Kind with
327
+
| ResolveNull ->
328
+
asyncVal {return ResolverLeaf { Name = ctx.ExecutionInfo.Identifier; Value = None }}
329
+
|_->
330
+
match returnDef with
331
+
| Object objdef ->
332
+
match ctx.ExecutionInfo.Kind with
333
+
| SelectFields fields ->
334
+
match value with
335
+
| Some v -> buildObjectFields fields objdef ctx fieldExecuteMap name v
336
+
| None ->
337
+
if ctx.ExecutionInfo.IsNullable
338
+
then asyncVal {return ResolverObjectNode { Name = name; Value = None; Children =[||]}}
339
+
else nullResolverError name
340
+
| kind -> failwithf "Unexpected value of ctx.ExecutionPlan.Kind: %A" kind
| kind -> failwithf "Unexpected value of ctx.ExecutionPlan.Kind: %A" kind
330
392
match value with
331
-
| Some v -> buildObjectFields fields objdef ctx fieldExecuteMap name v
393
+
| Some v ->
394
+
letresolvedDef= resolver v
395
+
match Map.tryFind resolvedDef.Name typeMap with
396
+
| Some fields -> buildObjectFields fields resolvedDef ctx fieldExecuteMap name v
397
+
| None -> asyncVal {return ResolverError { Name = name; Message = ctx.Schema.ParseError (GraphQLException (sprintf "GraphQL Interface '%s' is not implemented by the type '%s'" idef.Name resolvedDef.Name)); PathToOrigin =[]}}
332
398
| None ->
333
399
if ctx.ExecutionInfo.IsNullable
334
400
then asyncVal {return ResolverObjectNode { Name = name; Value = None; Children =[||]}}
335
401
else nullResolverError name
336
-
| kind -> failwithf "Unexpected value of ctx.ExecutionPlan.Kind: %A" kind
| kind -> failwithf "Unexpected value of ctx.ExecutionPlan.Kind: %A" kind
388
-
match value with
389
-
| Some v ->
390
-
letresolvedDef= resolver v
391
-
match Map.tryFind resolvedDef.Name typeMap with
392
-
| Some fields -> buildObjectFields fields resolvedDef ctx fieldExecuteMap name v
393
-
| None -> asyncVal {return ResolverError { Name = name; Message = ctx.Schema.ParseError (GraphQLException (sprintf "GraphQL Interface '%s' is not implemented by the type '%s'" idef.Name resolvedDef.Name)); PathToOrigin =[]}}
394
-
| None ->
395
-
if ctx.ExecutionInfo.IsNullable
396
-
then asyncVal {return ResolverObjectNode { Name = name; Value = None; Children =[||]}}
| kind -> failwithf "Unexpected value of ctx.ExecutionPlan.Kind: %A" kind
405
-
match value with
406
-
| Some v ->
407
-
letresolvedDef= resolver v
408
-
match Map.tryFind resolvedDef.Name typeMap with
409
-
| Some fields ->
410
-
// Make sure to propagate the original union type to the object node
411
-
buildObjectFields fields resolvedDef ctx fieldExecuteMap name (udef.ResolveValue v)
412
-
|> AsyncVal.map(fun tree ->
413
-
match tree with
414
-
| ResolverObjectNode node -> ResolverObjectNode { node with Value = value }
415
-
| t -> t)
416
-
| None -> asyncVal {return ResolverError { Name = name; Message = ctx.Schema.ParseError (GraphQLException (sprintf "GraphQL Union '%s' is not implemented by the type '%s'" udef.Name resolvedDef.Name)); PathToOrigin =[]}}
417
-
| None ->
418
-
if ctx.ExecutionInfo.IsNullable
419
-
then asyncVal {return ResolverObjectNode { Name = name; Value = None; Children =[||]}}
420
-
else nullResolverError name
421
-
|_-> failwithf "Unexpected value of returnDef: %O" returnDef
| kind -> failwithf "Unexpected value of ctx.ExecutionPlan.Kind: %A" kind
409
+
match value with
410
+
| Some v ->
411
+
letresolvedDef= resolver v
412
+
match Map.tryFind resolvedDef.Name typeMap with
413
+
| Some fields ->
414
+
// Make sure to propagate the original union type to the object node
415
+
buildObjectFields fields resolvedDef ctx fieldExecuteMap name (udef.ResolveValue v)
416
+
|> AsyncVal.map(fun tree ->
417
+
match tree with
418
+
| ResolverObjectNode node -> ResolverObjectNode { node with Value = value }
419
+
| t -> t)
420
+
| None -> asyncVal {return ResolverError { Name = name; Message = ctx.Schema.ParseError (GraphQLException (sprintf "GraphQL Union '%s' is not implemented by the type '%s'" udef.Name resolvedDef.Name)); PathToOrigin =[]}}
421
+
| None ->
422
+
if ctx.ExecutionInfo.IsNullable
423
+
then asyncVal {return ResolverObjectNode { Name = name; Value = None; Children =[||]}}
424
+
else nullResolverError name
425
+
|_-> failwithf "Unexpected value of returnDef: %O" returnDef
|_-> raise (MalformedQueryException (sprintf "GraphQL query defined variable '$%s' of type '%s' which is not an input type definition" vname (tdef.ToString()))))
0 commit comments