Commit cbf1bd25 authored by Karen Konou's avatar Karen Konou

[GQL] Team API definitions

parent d92b7bef
Pipeline #2953 failed with stage
in 0 seconds
...@@ -14,6 +14,7 @@ import Gargantext.Components.GraphQL.IMT as GQLIMT ...@@ -14,6 +14,7 @@ import Gargantext.Components.GraphQL.IMT as GQLIMT
import Gargantext.Components.GraphQL.Node (Node) import Gargantext.Components.GraphQL.Node (Node)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel) import Gargantext.Components.GraphQL.Tree (TreeFirstLevel)
import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM) import Gargantext.Components.GraphQL.User (User, UserInfo, UserInfoM)
import Gargantext.Components.GraphQL.Team (TeamMember, TeamDeleteM)
import Gargantext.Ends (Backend(..)) import Gargantext.Ends (Backend(..))
import Gargantext.Sessions (Session(..)) import Gargantext.Sessions (Session(..))
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
...@@ -77,7 +78,9 @@ type Schema ...@@ -77,7 +78,9 @@ type Schema
, users :: { user_id :: Int } ==> Array User , users :: { user_id :: Int } ==> Array User
, tree :: { root_id :: Int } ==> TreeFirstLevel , tree :: { root_id :: Int } ==> TreeFirstLevel
, annuaire_contacts :: { contact_id :: Int } ==> Array AnnuaireContact , annuaire_contacts :: { contact_id :: Int } ==> Array AnnuaireContact
, team :: { team_node_id :: Int } ==> Array TeamMember
} }
type Mutation type Mutation
= { update_user_info :: UserInfoM ==> Int } = { update_user_info :: UserInfoM ==> Int
, delete_team_membership :: TeamDeleteM ==> Array Int }
...@@ -2,10 +2,6 @@ module Gargantext.Components.GraphQL.Endpoints where ...@@ -2,10 +2,6 @@ module Gargantext.Components.GraphQL.Endpoints where
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Components.GraphQL.Node (Node, nodeParentQuery, nodesQuery)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel, treeFirstLevelQuery)
import Gargantext.Components.GraphQL.User (UserInfo, userInfoQuery)
import Data.Array as A import Data.Array as A
import Data.Either (Either(..)) import Data.Either (Either(..))
import Data.Maybe (Maybe(..)) import Data.Maybe (Maybe(..))
...@@ -13,6 +9,10 @@ import Effect.Aff (Aff) ...@@ -13,6 +9,10 @@ import Effect.Aff (Aff)
import Effect.Class (liftEffect) import Effect.Class (liftEffect)
import Gargantext.Components.GraphQL (queryGql) import Gargantext.Components.GraphQL (queryGql)
import Gargantext.Components.GraphQL.IMT as GQLIMT import Gargantext.Components.GraphQL.IMT as GQLIMT
import Gargantext.Components.GraphQL.Node (Node, nodeParentQuery, nodesQuery)
import Gargantext.Components.GraphQL.Team (TeamMember, teamQuery)
import Gargantext.Components.GraphQL.Tree (TreeFirstLevel, treeFirstLevelQuery)
import Gargantext.Components.GraphQL.User (UserInfo, userInfoQuery)
import Gargantext.Config.REST (RESTError(..), AffRESTError) import Gargantext.Config.REST (RESTError(..), AffRESTError)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Types (NodeType) import Gargantext.Types (NodeType)
...@@ -70,3 +70,11 @@ getTreeFirstLevel session id = do ...@@ -70,3 +70,11 @@ getTreeFirstLevel session id = do
{ tree } <- queryGql session "get tree first level" $ treeFirstLevelQuery `withVars` { id } { tree } <- queryGql session "get tree first level" $ treeFirstLevelQuery `withVars` { id }
liftEffect $ here.log2 "[getTreeFirstLevel] tree first level" tree liftEffect $ here.log2 "[getTreeFirstLevel] tree first level" tree
pure $ Right tree -- TODO: error handling pure $ Right tree -- TODO: error handling
getTeam :: Session -> Int -> AffRESTError TeamMember
getTeam session id = do
{ team } <- queryGql session "get team" $ teamQuery `withVars` { id }
liftEffect $ here.log2 "[getTree] data" team
pure $ case A.head team of
Nothing -> Left (CustomError $ "team node id=" <> show id <> " not found")
Just t -> Right t
module Gargantext.Components.GraphQL.Team where
import Gargantext.Prelude
import GraphQL.Client.Args (NotNull, (=>>))
import GraphQL.Client.Variable (Var(..))
type TeamMember
= { username :: String
, shared_folder_id :: Int
}
type TeamDeleteM
= { token :: NotNull String
, shared_folder_id :: Int
, team_node_id :: Int
}
teamQuery = { team: { team_node_id: Var :: _ "id" Int } =>>
{ username: unit
, shared_folder_id: unit }
}
\ No newline at end of file
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