Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-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
Przemyslaw Kaminski
haskell-gargantext
Commits
4ffbb128
Commit
4ffbb128
authored
Apr 28, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graphql] annuaire contacts endpoint
parent
6a8b0843
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
10 deletions
+90
-10
gargantext.cabal
gargantext.cabal
+4
-2
GraphQL.hs
src/Gargantext/API/GraphQL.hs
+11
-8
Annuaire.hs
src/Gargantext/API/GraphQL/Annuaire.hs
+75
-0
No files found.
gargantext.cabal
View file @
4ffbb128
cabal-version:
0.0.5.8.8
cabal-version:
1.12
-- This file has been generated from package.yaml by hpack version 0.34.4.
-- This file has been generated from package.yaml by hpack version 0.34.4.
--
--
-- see: https://github.com/sol/hpack
-- see: https://github.com/sol/hpack
name: gargantext
name: gargantext
version: 0.0.5.8.8
version:
0.0.5.8.8
synopsis: Search, map, share
synopsis: Search, map, share
description: Please see README.md
description: Please see README.md
category: Data
category: Data
...
@@ -95,6 +95,7 @@ library
...
@@ -95,6 +95,7 @@ library
Gargantext.Core.Viz.Phylo.SynchronicClustering
Gargantext.Core.Viz.Phylo.SynchronicClustering
Gargantext.Core.Viz.Types
Gargantext.Core.Viz.Types
other-modules:
other-modules:
ConcurrentTest
Gargantext.API.Admin.Auth
Gargantext.API.Admin.Auth
Gargantext.API.Admin.FrontEnd
Gargantext.API.Admin.FrontEnd
Gargantext.API.Admin.Orchestrator
Gargantext.API.Admin.Orchestrator
...
@@ -106,6 +107,7 @@ library
...
@@ -106,6 +107,7 @@ library
Gargantext.API.EKG
Gargantext.API.EKG
Gargantext.API.Flow
Gargantext.API.Flow
Gargantext.API.GraphQL
Gargantext.API.GraphQL
Gargantext.API.GraphQL.Annuaire
Gargantext.API.GraphQL.AsyncTask
Gargantext.API.GraphQL.AsyncTask
Gargantext.API.GraphQL.IMT
Gargantext.API.GraphQL.IMT
Gargantext.API.GraphQL.Node
Gargantext.API.GraphQL.Node
...
...
src/Gargantext/API/GraphQL.hs
View file @
4ffbb128
...
@@ -33,6 +33,7 @@ import Data.Proxy
...
@@ -33,6 +33,7 @@ import Data.Proxy
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
)
import
Gargantext.API.Admin.Auth.Types
(
AuthenticatedUser
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
)
import
Gargantext.API.Admin.Orchestrator.Types
(
JobLog
)
import
Gargantext.API.Prelude
(
HasJobEnv
'
)
import
Gargantext.API.Prelude
(
HasJobEnv
'
)
import
qualified
Gargantext.API.GraphQL.Annuaire
as
GQLA
import
qualified
Gargantext.API.GraphQL.AsyncTask
as
GQLAT
import
qualified
Gargantext.API.GraphQL.AsyncTask
as
GQLAT
import
qualified
Gargantext.API.GraphQL.IMT
as
GQLIMT
import
qualified
Gargantext.API.GraphQL.IMT
as
GQLIMT
import
qualified
Gargantext.API.GraphQL.Node
as
GQLNode
import
qualified
Gargantext.API.GraphQL.Node
as
GQLNode
...
@@ -64,7 +65,8 @@ import Gargantext.API.Admin.Types (HasSettings)
...
@@ -64,7 +65,8 @@ import Gargantext.API.Admin.Types (HasSettings)
-- | Represents possible GraphQL queries.
-- | Represents possible GraphQL queries.
data
Query
m
data
Query
m
=
Query
=
Query
{
imt_schools
::
GQLIMT
.
SchoolsArgs
->
m
[
GQLIMT
.
School
]
{
annuaire_contacts
::
GQLA
.
AnnuaireContactArgs
->
m
[
GQLA
.
AnnuaireContact
]
,
imt_schools
::
GQLIMT
.
SchoolsArgs
->
m
[
GQLIMT
.
School
]
,
job_logs
::
GQLAT
.
JobLogArgs
->
m
(
Map
Int
JobLog
)
,
job_logs
::
GQLAT
.
JobLogArgs
->
m
(
Map
Int
JobLog
)
,
nodes
::
GQLNode
.
NodeArgs
->
m
[
GQLNode
.
Node
]
,
nodes
::
GQLNode
.
NodeArgs
->
m
[
GQLNode
.
Node
]
,
node_parent
::
GQLNode
.
NodeParentArgs
->
m
[
GQLNode
.
Node
]
,
node_parent
::
GQLNode
.
NodeParentArgs
->
m
[
GQLNode
.
Node
]
...
@@ -100,13 +102,14 @@ rootResolver
...
@@ -100,13 +102,14 @@ rootResolver
=>
RootResolver
(
GargM
env
GargError
)
e
Query
Mutation
Undefined
=>
RootResolver
(
GargM
env
GargError
)
e
Query
Mutation
Undefined
rootResolver
=
rootResolver
=
RootResolver
RootResolver
{
queryResolver
=
Query
{
imt_schools
=
GQLIMT
.
resolveSchools
{
queryResolver
=
Query
{
annuaire_contacts
=
GQLA
.
resolveAnnuaireContacts
,
job_logs
=
GQLAT
.
resolveJobLogs
,
imt_schools
=
GQLIMT
.
resolveSchools
,
nodes
=
GQLNode
.
resolveNodes
,
job_logs
=
GQLAT
.
resolveJobLogs
,
node_parent
=
GQLNode
.
resolveNodeParent
,
nodes
=
GQLNode
.
resolveNodes
,
user_infos
=
GQLUserInfo
.
resolveUserInfos
,
node_parent
=
GQLNode
.
resolveNodeParent
,
users
=
GQLUser
.
resolveUsers
,
user_infos
=
GQLUserInfo
.
resolveUserInfos
,
tree
=
GQLTree
.
resolveTree
}
,
users
=
GQLUser
.
resolveUsers
,
tree
=
GQLTree
.
resolveTree
}
,
mutationResolver
=
Mutation
{
update_user_info
=
GQLUserInfo
.
updateUserInfo
}
,
mutationResolver
=
Mutation
{
update_user_info
=
GQLUserInfo
.
updateUserInfo
}
,
subscriptionResolver
=
Undefined
}
,
subscriptionResolver
=
Undefined
}
...
...
src/Gargantext/API/GraphQL/Annuaire.hs
0 → 100644
View file @
4ffbb128
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DuplicateRecordFields #-}
module
Gargantext.API.GraphQL.Annuaire
where
import
Control.Lens
import
Data.Morpheus.Types
(
GQLType
,
Resolver
,
QUERY
,
lift
)
import
Data.Proxy
import
Data.Text
(
Text
)
import
Gargantext.API.Prelude
(
GargM
,
GargError
)
import
Gargantext.Core.Mail.Types
(
HasMail
)
import
Gargantext.Database.Admin.Types.Hyperdata.Contact
(
HyperdataContact
,
ContactWho
,
cw_firstName
,
cw_lastName
,
hc_who
)
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
))
import
Gargantext.Database.Prelude
(
HasConnectionPool
,
HasConfig
)
import
Gargantext.Database.Query.Table.Context
(
getContextWith
)
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
data
AnnuaireContact
=
AnnuaireContact
{
ac_id
::
Int
,
ac_firstName
::
Maybe
Text
,
ac_lastName
::
Maybe
Text
}
deriving
(
Generic
,
GQLType
,
Show
)
-- | Arguments to the "user info" query.
data
AnnuaireContactArgs
=
AnnuaireContactArgs
{
contact_id
::
Int
}
deriving
(
Generic
,
GQLType
)
type
GqlM
e
env
=
Resolver
QUERY
e
(
GargM
env
GargError
)
-- | Function to resolve user from a query.
resolveAnnuaireContacts
::
(
HasConnectionPool
env
,
HasConfig
env
,
HasMail
env
)
=>
AnnuaireContactArgs
->
GqlM
e
env
[
AnnuaireContact
]
resolveAnnuaireContacts
AnnuaireContactArgs
{
contact_id
}
=
dbAnnuaireContacts
contact_id
-- | Inner function to fetch the user from DB.
dbAnnuaireContacts
::
(
HasConnectionPool
env
,
HasConfig
env
,
HasMail
env
)
=>
Int
->
GqlM
e
env
[
AnnuaireContact
]
dbAnnuaireContacts
contact_id
=
do
-- lift $ printDebug "[dbUsers]" user_id
-- user <- getUsersWithId user_id
-- hyperdata <- getUserHyperdata user_id
-- lift (map toUser <$> zip user hyperdata)
c
<-
lift
$
getContextWith
(
NodeId
contact_id
)
(
Proxy
::
Proxy
HyperdataContact
)
pure
[
toAnnuaireContact
(
contact_id
,
c
^.
node_hyperdata
)]
toAnnuaireContact
::
(
Int
,
HyperdataContact
)
->
AnnuaireContact
toAnnuaireContact
(
c_id
,
c_hyperdata
)
=
AnnuaireContact
{
ac_id
=
c_id
,
ac_firstName
=
c_hyperdata
^.
ac_firstNameL
,
ac_lastName
=
c_hyperdata
^.
ac_lastNameL
}
contactWhoL
::
Traversal'
HyperdataContact
ContactWho
contactWhoL
=
hc_who
.
_Just
ac_firstNameL
::
Traversal'
HyperdataContact
(
Maybe
Text
)
ac_firstNameL
=
contactWhoL
.
cw_firstName
ac_lastNameL
::
Traversal'
HyperdataContact
(
Maybe
Text
)
ac_lastNameL
=
contactWhoL
.
cw_lastName
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