diff options
| author | Eugen Wissner <belka@caraus.de> | 2023-02-24 17:14:43 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2023-02-24 17:14:43 +0100 |
| commit | 3b0da4f3d75f2edf60a0a29a015aab1ae14338da (patch) | |
| tree | fea135a06c471edece7e780289437eaba91172a1 /src | |
| parent | d83f75b3418d4f1caf4174e59464b50e385aac0e (diff) | |
| download | graphql-3b0da4f3d75f2edf60a0a29a015aab1ae14338da.tar.gz | |
Fix resolvers returning a list in the reverse order
Diffstat (limited to 'src')
| -rw-r--r-- | src/Language/GraphQL/Execute.hs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Language/GraphQL/Execute.hs b/src/Language/GraphQL/Execute.hs index 5ceb616..bbacdd2 100644 --- a/src/Language/GraphQL/Execute.hs +++ b/src/Language/GraphQL/Execute.hs @@ -39,6 +39,7 @@ import qualified Data.List.NonEmpty as NonEmpty import Data.Maybe (fromMaybe) import Data.Sequence (Seq) import qualified Data.Sequence as Seq +import qualified Data.Vector as Vector import Data.Text (Text) import qualified Data.Text as Text import Data.Typeable (cast) @@ -466,12 +467,12 @@ completeValue :: (MonadCatch m, Serialize a) completeValue (Out.isNonNullType -> False) _ _ Type.Null = pure null completeValue outputType@(Out.ListBaseType listType) fields errorPath (Type.List list) - = foldM go (0, []) list >>= coerceResult outputType . List . snd + = foldM go Vector.empty list >>= coerceResult outputType . List . Vector.toList where - go (index, accumulator) listItem = do - let updatedPath = Index index : errorPath - completedValue <- completeValue listType fields updatedPath listItem - pure (index + 1, completedValue : accumulator) + go accumulator listItem = + let updatedPath = Index (Vector.length accumulator) : errorPath + in Vector.snoc accumulator + <$> completeValue listType fields updatedPath listItem completeValue outputType@(Out.ScalarBaseType _) _ _ (Type.Int int) = coerceResult outputType $ Int int completeValue outputType@(Out.ScalarBaseType _) _ _ (Type.Boolean boolean) = |
