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
90d8379f
Verified
Commit
90d8379f
authored
Jan 16, 2023
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graphql] context endpoint implementation
parent
a6ec0726
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
89 additions
and
2 deletions
+89
-2
GraphQL.purs
src/Gargantext/Components/GraphQL.purs
+1
-0
Context.purs
src/Gargantext/Components/GraphQL/Context.purs
+80
-1
Endpoints.purs
src/Gargantext/Components/GraphQL/Endpoints.purs
+8
-1
No files found.
src/Gargantext/Components/GraphQL.purs
View file @
90d8379f
...
...
@@ -74,6 +74,7 @@ queryGql session name q = do
type Schema
= { imt_schools :: {} ==> Array GQLIMT.School
, contexts :: { context_id :: Int, node_id :: Int } ==> Array GQLCTX.NodeContext
, contexts_for_ngrams :: { corpus_id :: Int, ngrams_ids :: Array Int } ==> Array GQLCTX.Context
, nodes :: { node_id :: Int } ==> Array Node
, node_parent :: { node_id :: Int, parent_type :: String } ==> Array Node -- TODO: parent_type :: NodeType
, user_infos :: { user_id :: Int } ==> Array UserInfo
...
...
src/Gargantext/Components/GraphQL/Context.purs
View file @
90d8379f
module Gargantext.Components.GraphQL.Context
( NodeContext
( Context_
, Context
, Hyperdata_
, Hyperdata
, NodeContext
, NodeContext_
, nodeContextQuery
, NodeContextCategoryM
, contextsForNgramsQuery
) where
import Gargantext.Prelude
...
...
@@ -16,6 +21,40 @@ import Type.Proxy (Proxy(..))
import Data.Array as A
type Context_
= ( c_id :: Int
, c_name :: String
, c_typename :: Int
, c_hash_id :: String
, c_user_id :: Int
, c_parent_id :: Int
, c_hyperdata :: Maybe Hyperdata )
type Context = Record Context_
type Hyperdata_
= ( hrd_abstract :: String
, hrd_authors :: String
, hrd_bdd :: String
, hrd_doi :: String
, hrd_institutes :: String
, hrd_language_iso2 :: String
, hrd_page :: Int
, hrd_publication_date :: String
, hrd_publication_day :: Int
, hrd_publication_hour :: Int
, hrd_publication_minute :: Int
, hrd_publication_month :: Int
, hrd_publication_second :: Int
, hrd_publication_year :: Int
, hrd_source :: String
, hrd_title :: String
, hrd_url :: String
, hrd_uniqId :: String
, hrd_uniqIdBdd :: String )
type Hyperdata = Record Hyperdata_
type NodeContext_
= ( nc_id :: Maybe Int
, nc_node_id :: Int
...
...
@@ -44,6 +83,46 @@ nodeContextQuery
GGQL.getFieldsStandard (Proxy :: _ NodeContext)
}
type ContextsForNgramsQuery
= { contexts_for_ngrams :: Args
{ corpus_id :: Var "corpus_id" Int
, ngrams_ids :: Var "ngrams_ids" (Array Int)}
{ c_id :: Unit
, c_name :: Unit
, c_typename :: Unit
, c_hash_id :: Unit
, c_user_id :: Unit
, c_parent_id :: Unit
, c_hyperdata ::
{ hrd_abstract :: Unit
, hrd_authors :: Unit
, hrd_bdd :: Unit
, hrd_doi :: Unit
, hrd_institutes :: Unit
, hrd_language_iso2 :: Unit
, hrd_page :: Unit
, hrd_publication_date :: Unit
, hrd_publication_day :: Unit
, hrd_publication_hour :: Unit
, hrd_publication_minute :: Unit
, hrd_publication_month :: Unit
, hrd_publication_second :: Unit
, hrd_publication_year :: Unit
, hrd_source :: Unit
, hrd_title :: Unit
, hrd_url :: Unit
, hrd_uniqId :: Unit
, hrd_uniqIdBdd :: Unit }
}
}
contextsForNgramsQuery :: ContextsForNgramsQuery
contextsForNgramsQuery
= { contexts_for_ngrams:
{ corpus_id: Var :: _ "corpus_id" Int
, ngrams_ids: Var :: _ "ngrams_ids" (Array Int) } =>>
GGQL.getFieldsStandard (Proxy :: _ Context)
}
------------------------------------------------------------------------
type NodeContextCategoryM
...
...
src/Gargantext/Components/GraphQL/Endpoints.purs
View file @
90d8379f
...
...
@@ -101,12 +101,19 @@ deleteTeamMembership session sharedFolderId teamNodeId = do
getNodeContext :: Session -> Int -> Int -> AffRESTError GQLCTX.NodeContext
getNodeContext session context_id node_id = do
{ contexts } <- queryGql session "get node context" $ GQLCTX.nodeContextQuery `withVars` { context_id, node_id }
{ contexts } <- queryGql session "get node context" $
GQLCTX.nodeContextQuery `withVars` { context_id, node_id }
--liftEffect $ here.log2 "[getNodeContext] node context" contexts
case A.head contexts of
Nothing -> pure $ Left $ CustomError "no node context found"
Just context -> pure $ Right context -- TODO: error handling
getContextsForNgrams :: Session -> Int -> Array Int -> AffRESTError (Array GQLCTX.Context)
getContextsForNgrams session corpus_id ngrams_ids = do
{ contexts_for_ngrams } <- queryGql session "get contexts for ngrams" $
GQLCTX.contextsForNgramsQuery `withVars` { corpus_id, ngrams_ids }
pure $ Right contexts_for_ngrams
updateNodeContextCategory :: Session -> Int -> Int -> Int -> AffRESTError Int
updateNodeContextCategory session context_id node_id category = do
client <- liftEffect $ getClient session
...
...
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