{- | Module : GraphQL Description : Here is methods to interpret your GraphQL-SQL query and process the Persistent results License : IPS Maintainer : jasonsychau@live.ca Stability : provisional is a link to the official documentations. You can learn and get a feel for how can you implement this package. This is the main module to interpret your queries. The expected query type is a single string to comprise all your GraphQL queries and fragments. When errors are encountered, this module is simply going to throw an uncaught Exception. The Exception name is some hint to where was the error encountered. -} module GraphQL ( -- * Functions module GraphQL, -- * Server data types module Model.ServerObjectTypes ) where import Data.Text (Text) import qualified Components.Parsers.QueryParser as QP import qualified Components.DataProcessors.PersistentDataProcessor as DP import Model.ServerObjectTypes import GraphQLHelper {- | Function processQueryString: This the function to call to get queries from a GraphQL query. The ordered arguments are: - the GraphQL query as a string - a list of tuple of String and list of String that is unique server object names and all names that are referencing then with any query - a list of tuple of String and list of String that is exact same unique server object names while the list is the valid server object scalar subfields as they are spelt in the database - a list of tuple of String and list of String that is exact same unique server object names while the list is the valid server object nested object subfields as they are referenced in the next list of relationship tables - a list of tuple of String, String, and list of String that is above server object names to make an identity name, a reference name, and a list of String that is identity table, escape identity column name, reference table, arrival reference column name, and an from-to order of intermediate table triplet strings of intermediate table name, intermediate table arrival column name, and intermediate table departure column name The return value is a tuple of server representation objects and a list of list of sql queries. The first list is holding lists that are grouping queries from the same GraphQL query. The inner list is holding the String value sql queries. The server representation objects is later used to format database results to the GraphQL return value syntax. -} processQueryString :: String -- ^ This is the given GraphQL query. -> [(String,[String])] -- ^ This is the ServerObject to list of query reference names. -> [(String,[String])] -- ^ This is the ServerObject to list of valid scalar subfields (which are exactly named after database column names). -> [(String,[String])] -- ^ This is the ServerObject to list of valid nested object subfields (which are exactly named after the from and to strings within the last function argument). -> [(String,[String])] -- ^ This is the ServerObject to list of database table names (which are exact references to table names). -> [(String,String,[String])] -- ^ This is the ServerObject to list of from-to-and intermediate triplet strings as described above to identify all GraphQL relationships with database sequences. -> ([RootObject],[[String]]) -- ^ The return value is one tuple with server objects and list of grouped sql query strings. processQueryString str svrobjs sss sos sodn sor = checkObjects sss sos sodn sor $ flip checkString svrobjs $ QP.processString str {- | Function processPersistentData: This is the function to call after casting PersistValues to Text from processQueryString. The ordered arguments are: - all the data that is cast to Text type - an unmodified copy of the RootObject list that is returned from processQueryString. The return result is a string to resemble the GraphQL return value. -} processPersistentData :: [[[[Text]]]] -- ^ This is the unmodified Persistent database query return value (a list of GraphQL-grouped results list of SQL query results list of data row lists). -> [RootObject] -- ^ This is the unmodified server objects that was composed from previous processQueryString function. -> String -- ^ The return value is a string type to describe the GraphQL-organized return values. processPersistentData dt ro = DP.processReturnedValues ro dt