Node.purs 1.43 KB
Newer Older
1 2 3 4
module Gargantext.Components.GraphQL.Node where

import Gargantext.Prelude

5
import Data.Maybe (Maybe)
6
import GraphQL.Client.Args (Args, (=>>))
7
import GraphQL.Client.Variable (Var(..))
8 9
import Gargantext.Utils.GraphQL as GGQL
import Type.Proxy (Proxy(..))
10 11


12 13 14 15 16 17
type Corpus
  = { id           :: Int
    , name         :: String
    , parent_id    :: Int
    , type_id      :: Int }

18 19 20 21 22 23
type Node
  = { id        :: Int
    , name      :: String
    , parent_id :: Int
    , type_id   :: Int }

24 25 26 27 28 29 30 31
type NodesCorpusQuery =
  { nodes_corpus :: Args
             { corpus_id :: Var "id" Int }
             { id :: Unit
             , name :: Unit
             , parent_id :: Unit
             , type_id :: Unit } }

32 33 34 35 36 37 38 39 40
type NodesQuery =
  { nodes :: Args
       { node_id :: Var "id" Int }
       { id :: Unit
       , name :: Unit
       , parent_id :: Unit
       , type_id :: Unit } }

nodesQuery :: NodesQuery
41
nodesQuery = { nodes: { node_id: Var :: _ "id" Int } =>>
42
               GGQL.getFieldsStandard (Proxy :: _ Node)
43 44
             }

45 46 47 48 49
nodesCorpusQuery :: NodesCorpusQuery
nodesCorpusQuery = { nodes_corpus: { corpus_id: Var :: _ "id" Int } =>>
               GGQL.getFieldsStandard (Proxy :: _ Corpus)
             }

50 51
nodeParentQuery = { node_parent: { node_id: Var :: _ "id" Int
                                 , parent_type: Var :: _ "parent_type" String } =>>  -- TODO parent_type :: NodeType
52
                    GGQL.getFieldsStandard (Proxy :: _ Node)
53
                  }