Tree.purs 1.13 KB
Newer Older
1 2 3 4 5
module Gargantext.Components.GraphQL.Tree where

import Gargantext.Prelude

import Data.Maybe (Maybe)
6
import Gargantext.Routes (AppRoute)
7 8 9 10 11 12 13 14
import Gargantext.Types (NodeType)
import GraphQL.Client.Args ((=>>))
import GraphQL.Client.Variable (Var(..))

type TreeNode =
  { name      :: String
  , id        :: Int
  , node_type :: NodeType
15
  , parent_id :: Maybe Int
16 17 18 19 20 21 22
  }
type TreeFirstLevel =
  { root     :: TreeNode
  , children :: Array TreeNode
  , parent   :: Maybe TreeNode
  }

23 24 25 26
type BreadcrumbInfo =
  { parents   :: Array TreeNode }


27 28 29 30
treeFirstLevelQuery = { tree: { root_id: Var :: _ "id" Int} =>>
  { root: { name: unit
          , node_type: unit
          , id: unit
31
          , parent_id: unit
32 33 34 35
          }
  , children: { name: unit
              , node_type: unit
              , id: unit
36
              , parent_id: unit
37 38 39 40
              }
  , parent: { name: unit
            , node_type: unit
            , id: unit
41
            , parent_id: unit
42 43 44
            }
  }
 }
45

46
breadcrumbQuery = { tree_branch: { node_id: Var :: _ "node_id" Int } =>>
47 48 49 50 51 52 53
  { parents: 
    { name: unit
    , node_type: unit
    , id: unit
    , parent_id: unit
    }
  }
54
}