File tree Expand file tree Collapse file tree 1 file changed +16
-7
lines changed
src/FSharp.Data.GraphQL.Server.Middleware Expand file tree Collapse file tree 1 file changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ namespace FSharp.Data.GraphQL.Server.Middleware
22
33open System
44open System.Collections .Immutable
5+ open System.Linq
56open FsToolkit.ErrorHandling
67
78open FSharp.Data .GraphQL
@@ -28,13 +29,21 @@ module TypeSystemExtensions =
2829 member this.ResolveAbstractionFilter ( typeMap : TypeMap ) =
2930 match this.Kind with
3031 | ResolveAbstraction typeFields ->
31- let getType name =
32- match typeMap.TryFind name with
33- | ValueSome tdef -> tdef.Type
34- | ValueNone -> raise ( MalformedGQLQueryException ( $" Type '{name}' not found in schema." ))
35- match typeFields.Keys |> Seq.map getType |> Seq.toList with
36- | [] -> ValueNone
37- | filters -> ValueSome ( OfTypes filters)
32+ match this.ReturnDef with
33+ | :? UnionDef as union when
34+ union.Options
35+ |> Seq.map _. Name
36+ |> Seq.sort
37+ |> _. SequenceEqual( typeFields.Keys |> Seq.sort)
38+ ->
39+ ValueNone
40+ | _ ->
41+ let getType name = typeMap[ name]. Type
42+ typeFields.Keys
43+ |> Seq.map getType
44+ |> Seq.toList
45+ |> OfTypes
46+ |> ValueSome
3847 | _ -> ValueNone
3948
4049 type ResolveFieldContext with
You can’t perform that action at this time.
0 commit comments