graphql-w-persistent 0.1.0.3 → 0.1.0.4
raw patch · 5 files changed
+22/−20 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +5/−1
- graphql-w-persistent.cabal +1/−1
- src/Components/DataProcessors/PersistentDataProcessor.hs +8/−11
- src/Components/Parsers/QueryParser.hs +6/−4
- src/GraphQL.hs +2/−3
ChangeLog.md view
@@ -14,4 +14,8 @@ ## 0.1.0.3 -- 2018-10-18 -* Update documentation+* Update documentation and Bug fix + +## 0.1.0.4 -- 2018-10-19 + +* Fix type heirarchies and arguments
graphql-w-persistent.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change -version: 0.1.0.3 +version: 0.1.0.4 -- A short (one-line) description of the package. synopsis: Haskell GraphQL query parser-interpreter-data processor.
src/Components/DataProcessors/PersistentDataProcessor.hs view
@@ -12,25 +12,22 @@ -- with root objects we want one json representation of separate graphql results... processReturnedValues :: [RootObject] -> [[[[Text]]]] -> String -processReturnedValues robjs rlts = encodeStrict $ toJSObject [("data", toJSObject [processReturnedValue x y | (x,y)<- zip robjs $ groupSingleQueryResults rlts])] --- with separated sql query results, we want a list of data rows that are separated by only graphql query... -groupSingleQueryResults :: [[[[Text]]]] -> [[[Text]]] -groupSingleQueryResults rlts = [foldr (\y z -> y++z) [] x | x<-rlts] +processReturnedValues robjs rlts = encodeStrict $ toJSObject [("data", toJSObject [processReturnedValue x y | (x,y) <- zip robjs rlts])] -- with qraphql query object and sql return data, we want json representation on graphql query results... -processReturnedValue :: RootObject -> [[Text]] -> (String, JSValue) +processReturnedValue :: RootObject -> [[[Text]]] -> (String, JSValue) processReturnedValue (NestedObject alias name _ _ sfs) rlts = (if (alias==Nothing) then name else (fromJust alias), showJSONs $ processSubFields sfs rlts) -- with SubFields and data rows, we want json representation on qraphql query data -processSubFields :: [Field] -> [[Text]] -> [JSValue] +processSubFields :: [Field] -> [[[Text]]] -> [JSValue] processSubFields _ [] = [] -processSubFields sfs rlts = ((showJSON $ toJSObject $ composeGraphQlRow sfs $ fetchGraphQlRow rlts):(processSubFields sfs $ removeDataRow rlts)) +processSubFields sfs rlts = foldr (\x y -> x++y) [] [((showJSON $ toJSObject $ composeGraphQlRow sfs $ fetchGraphQlRow typ):(processSubFields sfs [removeDataRow typ])) |typ<-rlts,(length typ)>0] composeGraphQlRow :: [Field] -> [[Text]] -> [(String,JSValue)] -composeGraphQlRow [] [[]] = [] -- done -composeGraphQlRow [] ([]:t) = [] -- done +composeGraphQlRow [] ([]:t) = [] -- done +-- composeGraphQlRow _ [] = [] -- no data +composeGraphQlRow _ ([]:t) = E.throw EOFDataProcessingException composeGraphQlRow [] _ = E.throw EOFDataProcessingException -composeGraphQlRow _ [[]] = E.throw EOFDataProcessingException composeGraphQlRow (a:b) ((h:t):j) | (isLeft a)==True = (((getScalarFieldLabel $ fromLeft (E.throw InvalidScalarException) a), (showJSON h)):(composeGraphQlRow b (removeNDataColumns 1 ((h:t):j)))) - | otherwise = (((getNestedObjectFieldLabel $ fromRight (E.throw InvalidObjectException) a), showJSONs (processSubFields (getSubFields $ fromRight (E.throw InvalidObjectException) a) (pullNDataColumns nestedObjectFieldCount ((h:t):j)))):(composeGraphQlRow b (removeNDataColumns nestedObjectFieldCount ((h:t):j)))) + | otherwise = (((getNestedObjectFieldLabel $ fromRight (E.throw InvalidObjectException) a), showJSONs (processSubFields (getSubFields $ fromRight (E.throw InvalidObjectException) a) [pullNDataColumns nestedObjectFieldCount ((h:t):j)])):(composeGraphQlRow b (removeNDataColumns nestedObjectFieldCount ((h:t):j)))) where nestedObjectFieldCount = (countNestedObjectQueriedFields $ fromRight (E.throw InvalidObjectException) a) fetchGraphQlRow :: [[Text]] -> [[Text]]
src/Components/Parsers/QueryParser.hs view
@@ -241,7 +241,7 @@ separateRootObjectsHelper :: String -> String -> [(String,[String])] -> [RootObject] separateRootObjectsHelper [] _ _ = [] separateRootObjectsHelper (h:t) acc svrobjs - | h=='{' = (((createNestedObject (acc++[h]++(extractLevel t)) svrobjs) :: RootObject):separateRootObjectsHelper (removeLevel t) [] svrobjs) + | h=='{' = (((createNestedObject (acc++[h]++(extractLevel t)) svrobjs) :: RootObject):separateRootObjectsHelper (removeLevel t) "" svrobjs) | otherwise = separateRootObjectsHelper t (acc++[h]) svrobjs -- create root object from block -- EFFECTS: passing code block to parseSubFields where block is not including root object opening and closing curly brackets. @@ -282,7 +282,7 @@ parseSubSelection :: String -> SubSelection parseSubSelection [] = Nothing :: SubSelection parseSubSelection (h:t) - | h=='('&&(elem ':' t)==True&&(elem ')' t)==True = Just (ScalarType (Nothing :: Alias) ((removeSpaces (foldr (\x y -> if x==':' then [] else x:y) "" t)) :: Name) (Nothing :: Transformation) ((Just $ removeSpaces $ foldl (\y x -> if x==':' then [] else (y++[x])) "" (foldr (\x y -> if x==')' then [] else x:y) "" t)) :: Argument)) :: SubSelection + | h=='('&&(elem ':' t)==True&&(elem ')' t)==True = Just (ScalarType (Nothing :: Alias) ((removeSideSpaces (foldr (\x y -> if x==':' then [] else x:y) "" t)) :: Name) (Nothing :: Transformation) ((Just $ removeSideSpaces $ foldl (\y x -> if x==':' then [] else (y++[x])) "" (foldr (\x y -> if x==')' then [] else x:y) "" t)) :: Argument)) :: SubSelection | otherwise = parseSubSelection t -- REQUIRES: code block on nested object subfields where nested object opening and closing curly brackets are not included parseSubFields :: String -> [(String,[String])] -> [Field] @@ -347,15 +347,17 @@ parseTransformation :: String -> Transformation parseTransformation [] = Nothing :: Transformation parseTransformation str - | (elem '(' str)&&(elem ':' str) = (Just $ removeSpaces $ foldr (\x y -> if x==':' then [] else x:y) "" $ foldl (\y x -> if x=='(' then [] else y++[x]) "" str) :: Transformation + | (elem '(' str)&&(elem ':' str) = (Just $ removeSideSpaces $ foldr (\x y -> if x==':' then [] else x:y) "" $ foldl (\y x -> if x=='(' then [] else y++[x]) "" str) :: Transformation | (elem '(' str) = E.throw SyntaxException | otherwise = Nothing :: Transformation parseArgument :: String -> Argument parseArgument [] = Nothing :: Argument parseArgument str - | (elem ')' str)&&(elem ':' str) = (Just $ removeSpaces $ foldr (\x y -> if x==')' then [] else x:y) "" $ foldl (\y x -> if x==':' then [] else y++[x]) "" str) :: Argument + | (elem ')' str)&&(elem ':' str) = (Just $ removeSideSpaces $ foldr (\x y -> if x==')' then [] else x:y) "" $ foldl (\y x -> if x==':' then [] else y++[x]) "" str) :: Argument | (elem ')' str) = E.throw SyntaxException | otherwise = Nothing :: Argument +removeSideSpaces :: String -> String +removeSideSpaces str = foldl (\y x -> if (x==' '&&(length y)==0) then [] else y++[x]) "" $ foldr (\x y -> if (x==' '&&(length y)==0) then [] else x:y) "" str -- parseOperation :: String -> Operation -- TODO: support mutations
src/GraphQL.hs view
@@ -27,10 +27,10 @@ -} module GraphQL ( -- * Functions - -- *** These are available methods to give access to the package interpretation, validation, and formatting features. + -- | These are available methods to give access to the package interpretation, validation, and formatting features. module GraphQL, -- * Server data types - -- *** These are server data types that are return from processQueryString. You do not need to know these to know how is this package used, but you'll get some insight to what is used to store and organize your GraphQL data. + -- | These are server data types that are return from processQueryString. You do not need to know these to know how is this package used, but you'll get some insight to what is used to store and organize your GraphQL data. module Model.ServerObjectTypes ) where @@ -40,7 +40,6 @@ import Model.ServerObjectTypes import GraphQLHelper --- * {- | This is the function to call to get queries from a GraphQL query.