diff options
| author | Eugen Wissner <belka@caraus.de> | 2021-03-14 12:19:30 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2021-03-14 12:19:30 +0100 |
| commit | 4d762d635666a954000be76832303eb3170f4ee2 (patch) | |
| tree | b12e77888d7dc6d7f81b2be4311da56d8e96494d /src/Language/GraphQL/Validate.hs | |
| parent | cbccb9ed0b32167dbb4de16eb5143dd62f9f3159 (diff) | |
| download | graphql-4d762d635666a954000be76832303eb3170f4ee2.tar.gz | |
Add location information to list values
Diffstat (limited to 'src/Language/GraphQL/Validate.hs')
| -rw-r--r-- | src/Language/GraphQL/Validate.hs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/Language/GraphQL/Validate.hs b/src/Language/GraphQL/Validate.hs index ea72018..b0c47cd 100644 --- a/src/Language/GraphQL/Validate.hs +++ b/src/Language/GraphQL/Validate.hs @@ -315,8 +315,8 @@ constValue (Validation.ValueRule _ rule) valueType = go valueType go inputObjectType value'@(Full.Node (Full.ConstObject fields) _) = foldMap (forEach inputObjectType) (Seq.fromList fields) |> rule inputObjectType value' - go listType value'@(Full.Node (Full.ConstList values) location') - = embedListLocation go listType values location' + go listType value'@(Full.Node (Full.ConstList values) _location) + = embedListLocation go listType values |> rule listType value' go anotherValue value' = pure $ rule anotherValue value' forEach inputObjectType Full.ObjectField{value = value', ..} = @@ -421,16 +421,15 @@ argument rule argumentType (Full.Argument _ value' _) = where valueType (In.Argument _ valueType' _) = valueType' --- valueTypeFromList :: Maybe In.Type -> Maybe In.Type +-- Applies a validation rule to each list value and merges returned errors. embedListLocation :: forall a m . (Maybe In.Type -> Full.Node a -> Seq m) -> Maybe In.Type - -> [a] - -> Full.Location + -> [Full.Node a] -> Seq m -embedListLocation go listType values location' +embedListLocation go listType = foldMap (go $ valueTypeFromList listType) - $ flip Full.Node location' <$> Seq.fromList values + . Seq.fromList where valueTypeFromList (Just (In.ListBaseType baseType)) = Just baseType valueTypeFromList _ = Nothing @@ -445,8 +444,8 @@ value (Validation.ValueRule rule _) valueType = go valueType go inputObjectType value'@(Full.Node (Full.Object fields) _) = foldMap (forEach inputObjectType) (Seq.fromList fields) |> rule inputObjectType value' - go listType value'@(Full.Node (Full.List values) location') - = embedListLocation go listType values location' + go listType value'@(Full.Node (Full.List values) _location) + = embedListLocation go listType values |> rule listType value' go anotherValue value' = pure $ rule anotherValue value' forEach inputObjectType Full.ObjectField{value = value', ..} = |
