Commit b0e60b8c authored by Karen Konou's avatar Karen Konou

[GQL] Encode NodeType as GQL type

parent 3cc3edfe
Pipeline #2610 failed with stage
in 54 minutes and 19 seconds
...@@ -6,13 +6,13 @@ module Gargantext.API.GraphQL.TreeFirstLevel where ...@@ -6,13 +6,13 @@ module Gargantext.API.GraphQL.TreeFirstLevel where
import Gargantext.Prelude import Gargantext.Prelude
import Data.Morpheus.Types (GQLType, lift, Resolver, QUERY) import Data.Morpheus.Types (GQLType, lift, Resolver, QUERY)
import GHC.Generics (Generic) import GHC.Generics (Generic)
import Data.Text (Text, pack) import Data.Text (Text)
import Gargantext.API.Prelude (GargM, GargError) import Gargantext.API.Prelude (GargM, GargError)
import Gargantext.Database.Prelude (HasConnectionPool, HasConfig) import Gargantext.Database.Prelude (HasConnectionPool, HasConfig)
import Gargantext.Core.Mail.Types (HasMail) import Gargantext.Core.Mail.Types (HasMail)
import qualified Gargantext.Database.Query.Tree as T import qualified Gargantext.Database.Query.Tree as T
import Gargantext.Database.Admin.Types.Node (allNodeTypes, NodeId (NodeId)) import Gargantext.Database.Admin.Types.Node (allNodeTypes, NodeId (NodeId))
import Gargantext.Core.Types (Tree, NodeTree) import Gargantext.Core.Types (Tree, NodeTree, NodeType)
import Gargantext.Core.Types.Main import Gargantext.Core.Types.Main
( Tree(TreeN), _tn_node, _tn_children, NodeTree(NodeTree, _nt_id, _nt_type), _nt_name ) ( Tree(TreeN), _tn_node, _tn_children, NodeTree(NodeTree, _nt_id, _nt_type), _nt_name )
...@@ -25,7 +25,7 @@ data TreeNode = TreeNode ...@@ -25,7 +25,7 @@ data TreeNode = TreeNode
{ {
name :: Text name :: Text
, id :: Int , id :: Int
, node_type :: Text , node_type :: NodeType
} deriving (Generic, GQLType) } deriving (Generic, GQLType)
data TreeFirstLevel = TreeFirstLevel data TreeFirstLevel = TreeFirstLevel
...@@ -53,7 +53,7 @@ toTree TreeN {_tn_node, _tn_children} = TreeFirstLevel ...@@ -53,7 +53,7 @@ toTree TreeN {_tn_node, _tn_children} = TreeFirstLevel
} }
toTreeNode :: NodeTree -> TreeNode toTreeNode :: NodeTree -> TreeNode
toTreeNode NodeTree {_nt_name, _nt_id, _nt_type} = TreeNode { name = _nt_name, id = id2int _nt_id, node_type = pack $ show _nt_type} toTreeNode NodeTree {_nt_name, _nt_id, _nt_type} = TreeNode { name = _nt_name, id = id2int _nt_id, node_type = _nt_type}
where where
id2int :: NodeId -> Int id2int :: NodeId -> Int
id2int (NodeId n) = n id2int (NodeId n) = n
......
...@@ -356,6 +356,8 @@ data NodeType = NodeUser ...@@ -356,6 +356,8 @@ data NodeType = NodeUser
deriving (Show, Read, Eq, Generic, Bounded, Enum) deriving (Show, Read, Eq, Generic, Bounded, Enum)
instance GQLType NodeType
allNodeTypes :: [NodeType] allNodeTypes :: [NodeType]
allNodeTypes = [minBound ..] allNodeTypes = [minBound ..]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment