{- |
Module      : Model.ServerObjectTypes
Description : Here is the data types for the server objects.
License     : IPS
Maintainer  : jasonsychau@live.ca
Stability   : provisional
-}
module Model.ServerObjectTypes where


-- | These are objects to represent GraphQL query roots.
type RootObjects = [RootObject]
type RootObject = NestedObject

-- | NestedObjects are the general object type. They are found as RootObjects or as object Subfields.
data NestedObject = NestedObject !Alias !Name !ServerObject !SubSelection !SubFields
                    deriving Show
type Alias = Maybe String
type ServerObject = String
type SubSelection = Maybe ScalarType
type SubFields = [Field]
type Field = Either ScalarType FieldObject
type FieldObject = Either NestedObject InlinefragmentObject
data InlinefragmentObject = InlinefragmentObject !ServerObject !SubFields
                    deriving Show

-- | ScalarTypes are the other subfield type. They are also found at object attributes.
data ScalarType = ScalarType !Alias !Name !Transformation !Argument
                -- deriving Eq
               deriving (Show,Eq)
type Transformation = Maybe String
type Argument = Maybe String

type Name = String

data Fragment = Fragment
    { name :: String
    , targetObject :: ServerObject
    , replacement :: String
    }

type SchemaSpecs = ([(String,[String])],[(String,[(String,String,[(String,[(String,String,String,String)])])])],[(String,[(String,[String])])],[(String,[String],String)],[(String,String,[String])],[(String,[String],[String])])

type QueryData = [(RootObject,[[String]])]