Verified Commit e67a7435 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

Merge branch 'dev' into 341-dev-websockets

parents 85353a92 49946361
## Version 0.0.7.1.6.1
* [FRONT][FIX][Display Phylomemy parameters (#580)](https://gitlab.iscpif.fr/gargantext/purescript-gargantext/issues/580)
* [BACK][FIX][Consider integrating Servant named routes (#271)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/271)
## Version 0.0.7.1.6 ## Version 0.0.7.1.6
* [BACK][REFACT][Consider integrating Servant named routes (#271)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/271) * [BACK][REFACT][Consider integrating Servant named routes (#271)](https://gitlab.iscpif.fr/gargantext/haskell-gargantext/issues/271)
......
...@@ -5,7 +5,7 @@ cabal-version: 3.4 ...@@ -5,7 +5,7 @@ cabal-version: 3.4
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
name: gargantext name: gargantext
version: 0.0.7.1.6 version: 0.0.7.1.6.1
synopsis: Search, map, share synopsis: Search, map, share
description: Please see README.md description: Please see README.md
category: Data category: Data
......
...@@ -15,6 +15,8 @@ Portability : POSIX ...@@ -15,6 +15,8 @@ Portability : POSIX
{-# LANGUAGE KindSignatures #-} -- for use of Endpoint (name :: Symbol) {-# LANGUAGE KindSignatures #-} -- for use of Endpoint (name :: Symbol)
{-# LANGUAGE PartialTypeSignatures #-} -- to automatically use suggested type hole signatures during compilation {-# LANGUAGE PartialTypeSignatures #-} -- to automatically use suggested type hole signatures during compilation
{-# LANGUAGE TypeOperators #-} {-# LANGUAGE TypeOperators #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeApplications #-}
module Gargantext.API.GraphQL where module Gargantext.API.GraphQL where
...@@ -46,16 +48,9 @@ import Gargantext.Core.NLP (HasNLPServer) ...@@ -46,16 +48,9 @@ import Gargantext.Core.NLP (HasNLPServer)
import Gargantext.Database.Prelude (CmdCommon) import Gargantext.Database.Prelude (CmdCommon)
import Gargantext.Prelude hiding (ByteString) import Gargantext.Prelude hiding (ByteString)
import Servant import Servant
( (:<|>) (..)
, (:>)
, Get
, JSON
, Post
, ReqBody
, ServerT
)
import Servant.Auth qualified as SA import Servant.Auth qualified as SA
import Servant.Auth.Server qualified as SAS import Servant.Auth.Server qualified as SAS
import Servant.Server.Generic
-- | Represents possible GraphQL queries. -- | Represents possible GraphQL queries.
...@@ -151,34 +146,37 @@ app authenticatedUser policyManager = deriveApp (rootResolver authenticatedUser ...@@ -151,34 +146,37 @@ app authenticatedUser policyManager = deriveApp (rootResolver authenticatedUser
-- servant. -- servant.
-- | Servant route for the app we defined above. -- | Servant route for the app we defined above.
type GQAPI = ReqBody '[JSON] GQLRequest :> Post '[JSON] GQLResponse newtype GQAPI mode = GQAPI
-- type Schema = "schema" :> Get '[PlainText] Text { gqApi :: mode :- ReqBody '[JSON] GQLRequest :> Post '[JSON] GQLResponse
} deriving Generic
-- | Servant route for the playground. -- | Servant route for the playground.
type Playground = Get '[HTML] ByteString newtype Playground mode = Playground
-- type API' (name :: Symbol) = name :> (GQAPI :<|> Schema :<|> Playground) { playground :: mode :- Get '[HTML] ByteString
-- | Our API consists of `GQAPI` and `Playground`. } deriving Generic
type API = SA.Auth '[SA.JWT, SA.Cookie] AuthenticatedUser
:> "gql" :> (PolicyChecked GQAPI :<|> Playground) newtype GraphQLAPI mode = GraphQLAPI
{ graphQLAPI :: mode :- SA.Auth '[SA.JWT, SA.Cookie] AuthenticatedUser
:> "gql"
:> NamedRoutes GraphQLAPIEndpoints
} deriving Generic
data GraphQLAPIEndpoints mode = GraphQLAPIEndpoints
{ gqApiEp :: mode :- PolicyChecked (NamedRoutes GQAPI)
, playgroundEp :: mode :- NamedRoutes Playground
}
deriving Generic
gqapi :: Proxy API gqapi :: Proxy (ToServantApi GraphQLAPI)
gqapi = Proxy gqapi = Proxy
-- serveEndpoint ::
-- ( SubApp ServerApp e
-- , PubApp e
-- ) =>
-- [e -> IO ()] ->
-- App e IO ->
-- Server (API name)
-- serveEndpoint publish app' = (liftIO . httpPubApp publish app') :<|> withSchema app' :<|> pure httpPlayground
--
-- withSchema :: (Applicative f) => App e m -> f Text
-- withSchema = pure . LT.toStrict . decodeUtf8 . render
-- | Implementation of our API. -- | Implementation of our API.
--api :: Server API
api api
:: (Typeable env, CmdCommon env, HasJobEnv' env, HasSettings env) :: (Typeable env, CmdCommon env, HasJobEnv' env, HasSettings env)
=> ServerT API (GargM env BackendInternalError) => GraphQLAPI (AsServerT (GargM env BackendInternalError))
api (SAS.Authenticated auser) = (httpPubApp [] . app auser) :<|> pure httpPlayground api = GraphQLAPI $ \case
api _ = panicTrace "401 in graphql" -- SAS.throwAll (_ServerError # err401) (SAS.Authenticated auser)
-> GraphQLAPIEndpoints { gqApiEp = GQAPI . httpPubApp [] . app auser
, playgroundEp = Playground $ pure httpPlayground
}
_ -> panicTrace "401 in graphql" -- SAS.throwAll (_ServerError # err401)
...@@ -24,7 +24,7 @@ import GHC.Generics ...@@ -24,7 +24,7 @@ import GHC.Generics
import Gargantext.API.Admin.Auth.Types import Gargantext.API.Admin.Auth.Types
import Gargantext.API.Admin.FrontEnd (FrontEndAPI) import Gargantext.API.Admin.FrontEnd (FrontEndAPI)
import Gargantext.API.Admin.Orchestrator.Types import Gargantext.API.Admin.Orchestrator.Types
import Gargantext.API.GraphQL qualified as GraphQL import Gargantext.API.GraphQL
import Gargantext.API.Routes.Named.Private import Gargantext.API.Routes.Named.Private
import Gargantext.API.Routes.Named.Public import Gargantext.API.Routes.Named.Public
import Gargantext.API.Routes.Types import Gargantext.API.Routes.Types
...@@ -43,7 +43,7 @@ newtype API mode = API ...@@ -43,7 +43,7 @@ newtype API mode = API
data NamedAPI mode = NamedAPI data NamedAPI mode = NamedAPI
{ swaggerAPI :: mode :- SwaggerSchemaUI "swagger-ui" "swagger.json" { swaggerAPI :: mode :- SwaggerSchemaUI "swagger-ui" "swagger.json"
, backendAPI :: mode :- NamedRoutes BackEndAPI , backendAPI :: mode :- NamedRoutes BackEndAPI
, graphqlAPI :: mode :- GraphQL.API -- FIXME(adn) convert to named! , graphqlAPI :: mode :- NamedRoutes GraphQLAPI -- FIXME(adn) convert to named!
, frontendAPI :: mode :- FrontEndAPI , frontendAPI :: mode :- FrontEndAPI
, wsAPI :: mode :- NamedRoutes Dispatcher.WSAPI , wsAPI :: mode :- NamedRoutes Dispatcher.WSAPI
} deriving Generic } deriving Generic
......
...@@ -16,7 +16,7 @@ import Gargantext.API.Admin.EnvTypes (Env, env_dispatcher) ...@@ -16,7 +16,7 @@ import Gargantext.API.Admin.EnvTypes (Env, env_dispatcher)
import Gargantext.API.Admin.FrontEnd (frontEndServer) import Gargantext.API.Admin.FrontEnd (frontEndServer)
import Gargantext.API.Auth.PolicyCheck () import Gargantext.API.Auth.PolicyCheck ()
import Gargantext.API.Errors import Gargantext.API.Errors
import Gargantext.API.GraphQL qualified as GraphQL import Gargantext.API.GraphQL as GraphQL
import Gargantext.API.Prelude (GargM) import Gargantext.API.Prelude (GargM)
import Gargantext.API.Server.Named.Public (serverPublicGargAPI) import Gargantext.API.Server.Named.Public (serverPublicGargAPI)
import Gargantext.API.Routes.Named import Gargantext.API.Routes.Named
...@@ -57,7 +57,7 @@ server env = ...@@ -57,7 +57,7 @@ server env =
(transformJSON errScheme) (transformJSON errScheme)
(serverGargAPI (env ^. hasConfig . gc_url_backend_api)) (serverGargAPI (env ^. hasConfig . gc_url_backend_api))
, graphqlAPI = hoistServerWithContext , graphqlAPI = hoistServerWithContext
(Proxy :: Proxy GraphQL.API) (Proxy :: Proxy (NamedRoutes GraphQLAPI))
(Proxy :: Proxy AuthContext) (Proxy :: Proxy AuthContext)
(transformJSONGQL errScheme) (transformJSONGQL errScheme)
GraphQL.api GraphQL.api
......
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