Commit 0c1b48d1 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch '471-dev-get-contexts-for-ngrams-fix' into 'dev'

[graphql] simplify and_logic for get contexts for ngrams

See merge request !515
parents d41fd32c 85d48715
Pipeline #7683 passed with stages
in 24 minutes and 54 seconds
......@@ -109,3 +109,4 @@ To compile CSS (Sass):
nix-shell --run "npm run css"
```
......@@ -24,6 +24,7 @@ import Gargantext.Prelude
import Gargantext.Routes (AppRoute)
import Gargantext.Sessions (Session(..))
import Gargantext.Types (NodeType)
import Gargantext.Utils.GraphQL as GGQL
import Gargantext.Utils.Reactix as R2
import GraphQL.Client.BaseClients.Urql (UrqlClient, createClient)
import GraphQL.Client.Query (decodeGqlRes) --, mutationJson)
......@@ -149,7 +150,7 @@ type Schema =
{ annuaire_contacts :: { contact_id :: Int } -> Array AnnuaireContact
, context_ngrams :: { context_id :: Int, list_id :: Int } -> Array String
, contexts :: { context_id :: Int, node_id :: Int } -> Array GQLCTX.NodeContext
, contexts_for_ngrams :: { corpus_id :: Int, ngrams_terms :: Array String, and_logic :: String } -> Array GQLCTX.Context
, contexts_for_ngrams :: { corpus_id :: Int, ngrams_terms :: Array String, and_logic :: GGQL.GQLBoolean } -> Array GQLCTX.Context
, imt_schools :: {} -> Array GQLIMT.School
, languages :: {} -> Array GQLNLP.Language
, node_children :: { node_id :: Int, child_type :: NodeType } -> Array GQLNode.Node
......
......@@ -96,7 +96,7 @@ type ContextsForNgramsQuery =
Args
{ corpus_id :: Var "corpus_id" Int
, ngrams_terms :: Var "ngrams_terms" NgramsTerms
, and_logic :: Var "and_logic" String
, and_logic :: Var "and_logic" GGQL.GQLBoolean
}
{ c_id :: Unit
, c_score :: Unit
......@@ -134,7 +134,7 @@ contextsForNgramsQuery =
{ contexts_for_ngrams:
{ corpus_id: Var :: _ "corpus_id" Int
, ngrams_terms: Var :: _ "ngrams_terms" NgramsTerms
, and_logic: Var :: _ "and_logic" String
, and_logic: Var :: _ "and_logic" GGQL.GQLBoolean
} =>>
GGQL.getFieldsStandard (Proxy :: _ Context)
}
......
......@@ -23,6 +23,7 @@ import Gargantext.Prelude
import Gargantext.Routes (AppRoute(..))
import Gargantext.Sessions (Session(..))
import Gargantext.Types (CorpusId, NodeType)
import Gargantext.Utils.GraphQL (GQLBoolean(..))
import Gargantext.Utils.Reactix as R2
import GraphQL.Client.Args (onlyArgs)
import GraphQL.Client.Variables (withVars)
......@@ -213,7 +214,7 @@ getContextsForNgrams session corpus_id ngrams_terms logic = do
query = GQLCTX.contextsForNgramsQuery `withVars`
{ corpus_id
, ngrams_terms: GQLCTX.NgramsTerms ngrams_terms
, and_logic: show logic
, and_logic: GQLBoolean logic
}
eRes <- queryGql session "get contexts for ngrams" query
pure $ rmap _.contexts_for_ngrams eRes
......
......@@ -5,13 +5,16 @@ module Gargantext.Utils.GraphQL
( class GetFieldsStandard
, PropGetFieldsStandard
, getFieldsStandard
, GQLBoolean(..)
) where
import Prelude
import Data.Argonaut as Argonaut
import Data.HeytingAlgebra (class HeytingAlgebraRecord, tt)
import Data.Maybe (Maybe)
import GraphQL.Client.Args (class ArgGql)
import GraphQL.Client.Variables.TypeName (class VarTypeName)
import Heterogeneous.Mapping (class HMap, class Mapping, hmap)
import Prelude
import Prim.RowList (class RowToList)
import Type.Proxy (Proxy(..))
......@@ -54,3 +57,13 @@ instance propGetFieldsStandard ::
) =>
Mapping PropGetFieldsStandard t fields where
mapping PropGetFieldsStandard _ = getFieldsStandard (Proxy :: _ t)
newtype GQLBoolean = GQLBoolean Boolean
instance ArgGql Boolean GQLBoolean
instance ArgGql GQLBoolean GQLBoolean
instance VarTypeName GQLBoolean where
varTypeName _ = "Boolean!"
instance Argonaut.EncodeJson GQLBoolean where
encodeJson (GQLBoolean b) = Argonaut.encodeJson b
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