Project

General

Profile

Actions

Bug #609

closed

Wrong path order with array index

Added by Eugen Wissner 10 months ago. Updated 7 months ago.

Status:
Closed
Priority:
Normal
Category:
Executor
Target version:
% Done:

0%


Description

e.g.

{
  "data": null,
  "errors": [
    {
      ...,
      "path": [0, "positions", "unit"]
    }
  ]
}

should be path: ["positions", 0, "unit"].


Files

Actions #1

Updated by Eugen Wissner 10 months ago

  • Target version set to 1.0.2.1
Actions #3

Updated by Eugen Wissner 7 months ago

  • The patch should be rebased on the latest master. The biggest change was removing Aeson 1 support (Aeson 2 will provided by a separate package). The tests should run with cabal test --flags -json.
  • CHANGELOG entry.
  • Remove extra newlines at the end of the files ("HeroSchema.hs" has 3 trailing newlines).

The first let binding can be in the same line with let

  let someVar = ...
      anotherVar = ...

Or at least the bindings should be aligned with 4 spaces without a space after let (there is a trailing whitespace in Execute.hs):

diff --git a/src/Language/GraphQL/Execute.hs b/src/Language/GraphQL/Execute.hs
index 476cc50..06dbad0 100644
--- a/src/Language/GraphQL/Execute.hs
+++ b/src/Language/GraphQL/Execute.hs
@@ -402,17 +403,17 @@ executeField objectValue fields (viewResolver -> resolverPair) errorPath =
              then throwM e
              else returnError newError
     exceptionHandler errorLocation e =
-        let newPath = fieldsSegment fields : errorPath
-            newError = constructError e errorLocation newPath
+        let 
+            newError = constructError e errorLocation fieldErrorPath

diff --git a/graphql.cabal b/graphql.cabal
index 232b537..3323980 100644
--- a/graphql.cabal
+++ b/graphql.cabal
@@ -103,5 +104,7 @@ test-suite graphql-test
     megaparsec,
     scientific,
     text,
-    unordered-containers
+    unordered-containers,
+    containers >= 0.6.2 && < 0.7,
+    vector >= 0.12.3 && < 0.13

I think we can skip the versions for the test binary if the same dependencies are specified for the library itself; I suppose cabal will pick the same versions as for the library.

4 spaces indentation

Only where has 2 spaces indentation, e.g.

queryType :: ObjectType
queryType = Out.ObjectType "Query" Nothing []
    $ HashMap.fromList
        [ ("hero", Out.ValueResolver heroField heroResolver)
        ]
  where
    heroField = Out.Field Nothing (Out.NamedObjectType heroType)
        $ HashMap.singleton "id"
        $ In.Argument Nothing (In.NamedScalarType Type.id) Nothing
    heroResolver = pure $ Type.Object mempty

hlint

tests/Schemas/HeroSchema.hs:6:1-32: Warning: Unused LANGUAGE pragma
Found:
{-# LANGUAGE RecordWildCards #-}
Perhaps you should remove it.
Note: may require {-# LANGUAGE DisambiguateRecordFields #-} adding to the top of the file

1 hint

HeroSchema unused imports

tests/Schemas/HeroSchema.hs:10:1: warning: [-Wunused-imports]
The import of ‘SomeException’
from module ‘Control.Exception’ is redundant
|
10 | import Control.Exception (Exception(..), SomeException (SomeException))
|

tests/Schemas/HeroSchema.hs:15:1: warning: [-Wunused-imports]
The import of ‘Language.GraphQL.AST’ is redundant
except perhaps to import instances from ‘Language.GraphQL.AST’
To import instances alone, use: import Language.GraphQL.AST()
|
15 | import Language.GraphQL.AST (Name)
|

tests/Schemas/HeroSchema.hs:17:1: warning: [-Wunused-imports]
The qualified import of ‘Data.Vector’ is redundant
except perhaps to import instances from ‘Data.Vector’
To import instances alone, use: import Data.Vector()
|
17 | import qualified Data.Vector as Vector
|

tests/Schemas/HeroSchema.hs:19:1: warning: [-Wunused-imports]
The import of ‘Data.Text’ is redundant
except perhaps to import instances from ‘Data.Text’
To import instances alone, use: import Data.Text()
|
19 | import Data.Text (Text)

Actions #5

Updated by Eugen Wissner 7 months ago

  • Status changed from In review to Closed
Actions

Also available in: Atom PDF