module GraphQLHelper where

import qualified Control.Exception as E
import qualified Components.Parsers.QueryParser as QP
import qualified Components.ObjectHandlers.ServerObjectValidator as SOV
import qualified Components.QueryComposers.SQLQueryComposer as QC
import Model.ServerObjectTypes
import Model.ServerExceptions


checkString :: String -> [(String,[String])] -> [RootObject]
checkString str svrobjs = if (QP.validateQuery str)==True then (QP.parseStringToObjects str svrobjs) else E.throw SyntaxException
checkObjects :: [(String,[String])] -> [(String,[String])] -> [(String,[String])] -> [(String,String,[String])] -> [RootObject] -> ([RootObject],[[String]])
checkObjects sss sos sodn sor ros = if (SOV.checkObjectsAttributes ros sss sos)==True then (ros,QC.makeSqlQueries ros sodn sor) else E.throw InvalidObjectSubFieldException