Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
7b91b0fd
Commit
7b91b0fd
authored
Nov 04, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graphql] no need for Proxy fields in query
Also, more mutation work.
parent
cd39004e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
68 additions
and
60 deletions
+68
-60
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+6
-3
User.purs
src/Gargantext/Components/GraphQL/User.purs
+36
-34
Contact.purs
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
+26
-23
No files found.
src/Gargantext/Components/GraphQL.purs
View file @
7b91b0fd
...
...
@@ -7,7 +7,7 @@ import Effect (Effect)
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Foreign (unsafeToForeign, ForeignError)
import Gargantext.Components.GraphQL.User (User, UserInfo)
import Gargantext.Components.GraphQL.User (User, UserInfo
, UserInfoM
)
import Gargantext.Prelude
import Gargantext.Utils.Reactix as R2
import GraphQL.Client.Args (type (==>))
...
...
@@ -40,7 +40,7 @@ gqlQuery = queryWithDecoder (unsafeToForeign >>> JSON.read >>> lmap toJsonError
toJsonError :: NonEmptyList ForeignError -> JsonDecodeError
toJsonError = unsafeCoerce -- map ForeignErrors to JsonDecodeError as you wish
getClient :: Effect (Client UrqlClient Schema
Void
Void)
getClient :: Effect (Client UrqlClient Schema
Mutation
Void)
getClient = createClient { headers: [], url: "http://localhost:8008/gql" }
queryGql ::
...
...
@@ -51,7 +51,7 @@ queryGql ::
queryGql name q = do
--query client name q
client <- liftEffect getClient
gqlQuery (client :: Client UrqlClient Schema
Void
Void) name q
gqlQuery (client :: Client UrqlClient Schema
Mutation
Void) name q
--query_ "http://localhost:8008/gql" (Proxy :: Proxy Schema)
...
...
@@ -60,3 +60,6 @@ type Schema
= { user_infos :: { user_id :: Int } ==> Array UserInfo
, users :: { user_id :: Int } ==> Array User
}
type Mutation
= { update_user_info :: UserInfoM } ==> UserInfo
src/Gargantext/Components/GraphQL/User.purs
View file @
7b91b0fd
module Gargantext.Components.GraphQL.User where
import Gargantext.Prelude
import Data.Array as A
import Data.Lens (Lens', lens)
import Data.Maybe (Maybe(..), fromMaybe, maybe)
import Gargantext.Prelude
import Type.Proxy (Proxy(..))
...
...
@@ -23,7 +24,40 @@ type UserInfo
, ui_cwRole :: Maybe String
, ui_cwTouchPhone :: Maybe String
, ui_cwTouchMail :: Maybe String }
type UserInfoM
= { ui_id :: Int
, ui_username :: Maybe String
, ui_email :: Maybe String
, ui_title :: Maybe String
, ui_source :: Maybe String
, ui_cwFirstName :: Maybe String
, ui_cwLastName :: Maybe String
, ui_cwOrganization :: Maybe (Array String)
, ui_cwLabTeamDepts :: Maybe (Array String)
, ui_cwOffice :: Maybe String
, ui_cwCity :: Maybe String
, ui_cwCountry :: Maybe String
, ui_cwRole :: Maybe String
, ui_cwTouchPhone :: Maybe String
, ui_cwTouchMail :: Maybe String }
defaultUserInfoM :: UserInfoM
defaultUserInfoM =
{ ui_id: 0
, ui_username: Nothing
, ui_email: Nothing
, ui_title: Nothing
, ui_source: Nothing
, ui_cwFirstName: Nothing
, ui_cwLastName: Nothing
, ui_cwOrganization: Nothing
, ui_cwLabTeamDepts: Nothing
, ui_cwOffice: Nothing
, ui_cwCity: Nothing
, ui_cwCountry: Nothing
, ui_cwRole: Nothing
, ui_cwTouchPhone: Nothing
, ui_cwTouchMail: Nothing }
_ui_cwFirstName :: Lens' UserInfo String
_ui_cwFirstName = lens getter setter
where
...
...
@@ -106,35 +140,3 @@ showUser { u_id
, u_username
, u_email } = "[" <> show u_id <> "] " <> u_username <> " :: " <> u_email
showMUser u = maybe "" showUser u
-- Symbols
ui_id :: Proxy "ui_id"
ui_id = Proxy
ui_username :: Proxy "ui_username"
ui_username = Proxy
ui_email :: Proxy "ui_email"
ui_email = Proxy
ui_title :: Proxy "ui_title"
ui_title = Proxy
ui_source :: Proxy "ui_source"
ui_source = Proxy
ui_cwFirstName :: Proxy "ui_cwFirstName"
ui_cwFirstName = Proxy
ui_cwLastName :: Proxy "ui_cwLastName"
ui_cwLastName = Proxy
ui_cwCity :: Proxy "ui_cwCity"
ui_cwCity = Proxy
ui_cwCountry :: Proxy "ui_cwCountry"
ui_cwCountry = Proxy
ui_cwLabTeamDepts :: Proxy "ui_cwLabTeamDepts"
ui_cwLabTeamDepts = Proxy
ui_cwOrganization :: Proxy "ui_cwOrganization"
ui_cwOrganization = Proxy
ui_cwOffice :: Proxy "ui_cwOffice"
ui_cwOffice = Proxy
ui_cwRole :: Proxy "ui_cwRole"
ui_cwRole = Proxy
ui_cwTouchMail :: Proxy "ui_cwTouchMail"
ui_cwTouchMail = Proxy
ui_cwTouchPhone :: Proxy "ui_cwTouchPhone"
ui_cwTouchPhone = Proxy
src/Gargantext/Components/Nodes/Annuaire/User/Contact.purs
View file @
7b91b0fd
...
...
@@ -21,6 +21,7 @@ import Effect.Aff (Aff, launchAff_)
import Effect.Class (liftEffect)
import Gargantext.Components.App.Data (Boxes)
import Gargantext.Components.GraphQL (getClient, queryGql)
import Gargantext.Components.GraphQL.User (defaultUserInfoM)
import Gargantext.Components.InputWithEnter (inputWithEnter)
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs as Tabs
import Gargantext.Components.Nodes.Annuaire.User.Contacts.Types (Contact'(..), ContactData', ContactTouch(..), ContactWhere(..), ContactWho(..), HyperdataContact(..), HyperdataUser(..), _city, _country, _firstName, _labTeamDeptsJoinComma, _lastName, _mail, _office, _organizationJoinComma, _ouFirst, _phone, _role, _shared, _touch, _who, defaultContactTouch, defaultContactWhere, defaultContactWho, defaultHyperdataContact, defaultHyperdataUser)
...
...
@@ -34,7 +35,7 @@ import Gargantext.Types (NodeType(..))
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2
import GraphQL.Client.Args (type (==>), (=>>), onlyArgs)
import GraphQL.Client.Query (mutationOpts)
import GraphQL.Client.Query (mutationOpts
, mutation
)
import Reactix as R
import Reactix.DOM.HTML as H
import Record as Record
...
...
@@ -224,13 +225,15 @@ saveContactHyperdata session id = put session (Routes.NodeAPI Node (Just id) "")
saveUserInfo :: Session -> Int -> UserInfo -> Aff (Either RESTError Int)
saveUserInfo session id ui = do
-- TODO GraphQL
--pure $ Left $ CustomError "TODO implement graphql for saveUserInfo"
client <- liftEffect $ getClient
mutationOpts
(\m -> m)
client
"update user_info"
{ update_user_info: onlyArgs { ui_id: id } }
pure $ Left $ CustomError "TODO implement graphql for saveUserInfo"
-- client <- liftEffect $ getClient
-- res <- mutation
-- client
-- "update user_info"
-- { update_user_info: userInfo =>> { ui_id: unit } }
-- pure $ Right 0
-- where
-- userInfo = defaultUserInfoM { ui_id = id }
type AnnuaireLayoutProps = ( annuaireId :: Int, session :: Session | ReloadProps )
...
...
@@ -307,21 +310,21 @@ getUserInfo :: Session -> Int -> Aff (Either RESTError UserInfo)
getUserInfo session id = do
{ user_infos } <- queryGql "get user infos"
{ user_infos: { user_id: id } =>>
{ ui_id
, ui_username
, ui_email
, ui_title
, ui_source
, ui_cwFirstName
, ui_cwLastName
, ui_cwCity
, ui_cwCountry
, ui_cwLabTeamDepts
, ui_cwOrganization
, ui_cwOffice
, ui_cwRole
, ui_cwTouchMail
, ui_cwTouchPhone }
{ 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
}
}
liftEffect $ here.log2 "[getUserInfo] user infos" user_infos
pure $ case A.head user_infos of
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment