Node.purs 1.5 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 18
type Corpus
  = { id           :: Int
    , name         :: String
    , parent_id    :: Int
    , pubmedAPIKey :: Maybe String
    , type_id      :: Int }

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

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

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

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

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

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