Skip to content

Commit

Permalink
no-op
Browse files Browse the repository at this point in the history
  • Loading branch information
tirumaraiselvan committed Sep 25, 2019
1 parent 6443125 commit ba8f465
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 27 deletions.
11 changes: 4 additions & 7 deletions server/src-lib/Hasura/RQL/DDL/RemoteRelationship.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import Hasura.RQL.DDL.RemoteRelationship.Validate
import Hasura.RQL.Types

import qualified Data.HashMap.Strict as Map
import qualified Data.Text as T
import Instances.TH.Lift ()

runCreateRemoteRelationship ::
(MonadTx m, CacheRWM m, UserInfoM m) => RemoteRelationship -> m EncJSON
Expand All @@ -31,9 +29,8 @@ runCreateRemoteRelationshipP1 remoteRel@RemoteRelationship{..}= do
(scRemoteSchemas sc) of
Just rsCtx -> do
tableInfo <- onNothing (Map.lookup rrTable $ scTables sc) $ throw400 NotFound "table not found"
validation <-
getCreateRemoteRelationshipValidation remoteRel rsCtx tableInfo
case validation of
Left err -> throw400 RemoteSchemaError (T.pack (show err))
let remoteFieldE = validateRelationship remoteRel (rscGCtx rsCtx) tableInfo
case remoteFieldE of
Left err -> fromValidationError err
Right remoteField -> pure remoteField
Nothing -> throw400 RemoteSchemaError "No such remote schema"
Nothing -> throw400 NotFound ("no such remote schema: " <> remoteSchemaNameToTxt rrRemoteSchema)
24 changes: 5 additions & 19 deletions server/src-lib/Hasura/RQL/DDL/RemoteRelationship/Validate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
-- | Validate input queries against remote schemas.

module Hasura.RQL.DDL.RemoteRelationship.Validate
( getCreateRemoteRelationshipValidation
, validateRelationship
, validateRemoteArguments
, ValidationError(..)
( validateRelationship
, fromValidationError
) where

import Data.Bifunctor
Expand Down Expand Up @@ -46,22 +44,10 @@ data ValidationError
| UnsupportedEnum
deriving (Show, Eq)

-- Get a validation for the remote relationship proposal.
-- Success returns (RemoteField, TypeMap) where TypeMap is a map of additional types needed for the RemoteField
getCreateRemoteRelationshipValidation ::
(QErrM m)
=> RemoteRelationship
-> RemoteSchemaCtx
-> TableInfo PGColumnInfo
-> m (Either (NonEmpty ValidationError) RemoteField)
getCreateRemoteRelationshipValidation remoteRel rsCtx tableInfo = do
pure
(validateRelationship
remoteRel
(rscGCtx rsCtx)
tableInfo)
fromValidationError :: (QErrM m) => NonEmpty ValidationError -> m a
fromValidationError err = throw400 RemoteSchemaError (T.pack (show err))

-- | Validate a remote relationship given a context.
-- | Validate a remote relationship given a context and return a RemoteField
validateRelationship ::
RemoteRelationship
-> GC.RemoteGCtx
Expand Down
5 changes: 4 additions & 1 deletion server/src-lib/Hasura/RQL/Types/RemoteSchema.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Hasura.RQL.Types.RemoteSchema where

import Hasura.Prelude
import Hasura.RQL.Types.Common (NonEmptyText)
import Hasura.RQL.Types.Common (NonEmptyText (..))
import Language.Haskell.TH.Syntax (Lift)
import System.Environment (lookupEnv)

Expand All @@ -25,6 +25,9 @@ newtype RemoteSchemaName
, J.FromJSON, Q.ToPrepArg, Q.FromCol, DQuote
)

remoteSchemaNameToTxt :: RemoteSchemaName -> Text
remoteSchemaNameToTxt = unNonEmptyText . unRemoteSchemaName

data RemoteSchemaInfo
= RemoteSchemaInfo
{ rsUrl :: !N.URI
Expand Down

0 comments on commit ba8f465

Please sign in to comment.