Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
gargantext
haskell-gargantext
Commits
8425e355
Commit
8425e355
authored
Sep 05, 2023
by
Fabien Manière
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
create GraphQL route, using the SQL data with recursiveParents function
parent
12232f3a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
4 deletions
+39
-4
GraphQL.hs
src/Gargantext/API/GraphQL.hs
+6
-4
TreeFirstLevel.hs
src/Gargantext/API/GraphQL/TreeFirstLevel.hs
+32
-0
Tree.hs
src/Gargantext/Database/Query/Tree.hs
+1
-0
No files found.
src/Gargantext/API/GraphQL.hs
View file @
8425e355
...
...
@@ -83,6 +83,7 @@ data Query m
,
users
::
GQLUser
.
UserArgs
->
m
[
GQLUser
.
User
m
]
,
tree
::
GQLTree
.
TreeArgs
->
m
(
GQLTree
.
TreeFirstLevel
m
)
,
team
::
GQLTeam
.
TeamArgs
->
m
GQLTeam
.
Team
,
tree_branch
::
GQLTree
.
BreadcrumbArgs
->
m
(
GQLTree
.
BreadcrumbInfo
)
}
deriving
(
Generic
,
GQLType
)
data
Mutation
m
...
...
@@ -127,10 +128,11 @@ rootResolver authenticatedUser policyManager =
,
nodes
=
GQLNode
.
resolveNodes
authenticatedUser
policyManager
,
nodes_corpus
=
GQLNode
.
resolveNodesCorpus
,
node_parent
=
GQLNode
.
resolveNodeParent
,
user_infos
=
GQLUserInfo
.
resolveUserInfos
authenticatedUser
policyManager
,
users
=
GQLUser
.
resolveUsers
authenticatedUser
policyManager
,
tree
=
GQLTree
.
resolveTree
authenticatedUser
policyManager
,
team
=
GQLTeam
.
resolveTeam
}
,
user_infos
=
GQLUserInfo
.
resolveUserInfos
,
users
=
GQLUser
.
resolveUsers
,
tree
=
GQLTree
.
resolveTree
,
team
=
GQLTeam
.
resolveTeam
,
tree_branch
=
GQLTree
.
resolveBreadcrumb
}
,
mutationResolver
=
Mutation
{
update_user_info
=
GQLUserInfo
.
updateUserInfo
,
update_user_pubmed_api_key
=
GQLUser
.
updateUserPubmedAPIKey
,
delete_team_membership
=
GQLTeam
.
deleteTeamMembership
...
...
src/Gargantext/API/GraphQL/TreeFirstLevel.hs
View file @
8425e355
...
...
@@ -42,6 +42,19 @@ data TreeFirstLevel m = TreeFirstLevel
,
children
::
[
TreeNode
]
}
deriving
(
Generic
,
GQLType
)
data
BreadcrumbArgs
=
BreadcrumbArgs
{
node_id
::
Int
}
deriving
(
Generic
,
GQLType
)
data
BreadcrumbInfo
=
BreadcrumbInfo
{
parents
::
[
TreeNode
]
}
deriving
(
Generic
,
GQLType
)
type
GqlM
e
env
=
Resolver
QUERY
e
(
GargM
env
GargError
)
type
ParentId
=
Maybe
NodeId
resolveTree
::
(
CmdCommon
env
)
...
...
@@ -97,3 +110,22 @@ nodeToTreeNode N.Node {..} = if (fromNodeTypeId _node_typename /= NN.NodeFolderS
}
else
Nothing
resolveBreadcrumb
::
(
CmdCommon
env
)
=>
BreadcrumbArgs
->
GqlM
e
env
(
BreadcrumbInfo
)
resolveBreadcrumb
BreadcrumbArgs
{
node_id
}
=
dbRecursiveParents
node_id
convertDbTreeToTreeNode
::
T
.
DbTreeNode
->
TreeNode
convertDbTreeToTreeNode
T
.
DbTreeNode
{
_dt_name
,
_dt_nodeId
,
_dt_typeId
,
_dt_parentId
}
=
TreeNode
{
name
=
_dt_name
,
id
=
NN
.
unNodeId
_dt_nodeId
,
node_type
=
fromNodeTypeId
_dt_typeId
,
parent_id
=
NN
.
unNodeId
<$>
_dt_parentId
}
dbRecursiveParents
::
(
CmdCommon
env
)
=>
Int
->
GqlM
e
env
(
BreadcrumbInfo
)
dbRecursiveParents
node_id
=
do
let
nId
=
NodeId
node_id
dbParents
<-
lift
$
T
.
recursiveParents
nId
allNodeTypes
let
treeNodes
=
map
convertDbTreeToTreeNode
dbParents
let
breadcrumbInfo
=
BreadcrumbInfo
{
parents
=
treeNodes
}
pure
breadcrumbInfo
src/Gargantext/Database/Query/Tree.hs
View file @
8425e355
...
...
@@ -391,6 +391,7 @@ isIn cId docId = ( == [Only True])
AND nn.node2_id = ?;
|]
(
cId
,
docId
)
-- Recursive parents function to construct a breadcrumb
recursiveParents
::
NodeId
->
[
NodeType
]
->
Cmd
err
[
DbTreeNode
]
...
...
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