Commit 2a519769 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graphql] draft, to create user query template

parent 8acf12ac
Pipeline #2052 canceled with stage
let upstream =
https://github.com/purescript/package-sets/releases/download/psc-0.14.4-20210826/packages.dhall sha256:eee0765aa98e0da8fc414768870ad588e7cada060f9f7c23c37385c169f74d9f
https://github.com/purescript/package-sets/releases/download/psc-0.14.4-20211030/packages.dhall sha256:eee0765aa98e0da8fc414768870ad588e7cada060f9f7c23c37385c169f74d9f
let overrides =
{ globals =
......
......@@ -5,7 +5,9 @@ import Gargantext.Prelude
import Data.Array as A
import Data.Lens (Lens', lens)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import GraphQL.Client.Args (NotNull(..))
import GraphQL.Client.Args (NotNull(..), (=>>))
import GraphQL.Client.Variable (Var)
import GraphQL.Client.Variables (withVars)
import Type.Proxy (Proxy(..))
......@@ -58,7 +60,25 @@ type UserInfoM
-- , ui_cwRole: Nothing
-- , ui_cwTouchPhone: Nothing
-- , ui_cwTouchMail: Nothing }
userInfoQuery = { user_infos: { user_id: Var _ "id" Int } =>>
{ ui_id: unit
, ui_username: unit
, ui_email: unit
, ui_title: unit
, ui_source: unit
, ui_cwFirstName: unit
, ui_cwLastName: unit
, ui_cwCity: unit
, ui_cwCountry: unit
, ui_cwLabTeamDepts: unit
, ui_cwOrganization: unit
, ui_cwOffice: unit
, ui_cwRole: unit
, ui_cwTouchMail: unit
, ui_cwTouchPhone: unit }
}
_ui_cwFirstName :: Lens' UserInfo String
_ui_cwFirstName = lens getter setter
where
......
......@@ -35,6 +35,7 @@ import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import GraphQL.Client.Args (type (==>), IgnoreArg(..), OrArg(..), onlyArgs, (=>>))
import GraphQL.Client.Query (mutationOpts, mutation)
import GraphQL.Client.Variables (withVars)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
......@@ -320,24 +321,25 @@ getUserInfoWithReload {nodeId, session} = getUserInfo session nodeId -- getConta
getUserInfo :: Session -> Int -> Aff (Either RESTError UserInfo)
getUserInfo session id = do
{ user_infos } <- queryGql session "get user infos"
{ user_infos: { user_id: id } =>>
{ ui_id: unit
, ui_username: unit
, ui_email: unit
, ui_title: unit
, ui_source: unit
, ui_cwFirstName: unit
, ui_cwLastName: unit
, ui_cwCity: unit
, ui_cwCountry: unit
, ui_cwLabTeamDepts: unit
, ui_cwOrganization: unit
, ui_cwOffice: unit
, ui_cwRole: unit
, ui_cwTouchMail: unit
, ui_cwTouchPhone: unit }
}
-- { user_infos } <- queryGql session "get user infos"
-- { user_infos: { user_id: id } =>>
-- { ui_id: unit
-- , ui_username: unit
-- , ui_email: unit
-- , ui_title: unit
-- , ui_source: unit
-- , ui_cwFirstName: unit
-- , ui_cwLastName: unit
-- , ui_cwCity: unit
-- , ui_cwCountry: unit
-- , ui_cwLabTeamDepts: unit
-- , ui_cwOrganization: unit
-- , ui_cwOffice: unit
-- , ui_cwRole: unit
-- , ui_cwTouchMail: unit
-- , ui_cwTouchPhone: unit }
-- }
{ user_infos } <- queryGql session "get user infos" $ userInfoQuery `withVars` { id }
liftEffect $ here.log2 "[getUserInfo] user infos" user_infos
pure $ case A.head user_infos of
Nothing -> Left (CustomError $ "user with id " <> show id <> " not found")
......
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