Skip to content

Commit

Permalink
remove session argument (if exists) in arguments sequence of 'Functio…
Browse files Browse the repository at this point in the history
…nInfo'
  • Loading branch information
rakeshkky committed Oct 15, 2019
1 parent 087b8d9 commit 24aceda
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
7 changes: 2 additions & 5 deletions server/src-lib/Hasura/GraphQL/Schema.hs
Expand Up @@ -399,11 +399,8 @@ getRootFldsRole' tn primCols constraints fields funcs insM
, g fi $ fiDescription fi
)

mkFuncArgItemSeq fi =
let functionInputArgs = argsWithoutSessionArgument
(fiSessionVarArg fi) (fiInputArgs fi)
in Seq.fromList $ procFuncArgs functionInputArgs
$ \fa t -> FuncArgItem (G.Name t) (faName fa) (faHasDefault fa)
mkFuncArgItemSeq fi = Seq.fromList $ procFuncArgs (fiInputArgs fi)
$ \fa t -> FuncArgItem (G.Name t) (faName fa) (faHasDefault fa)


getSelPermission :: TableInfo PGColumnInfo -> RoleName -> Maybe SelPermInfo
Expand Down
12 changes: 1 addition & 11 deletions server/src-lib/Hasura/GraphQL/Schema/Function.hs
Expand Up @@ -3,7 +3,6 @@ module Hasura.GraphQL.Schema.Function
, mkFuncArgsInp
, mkFuncQueryFld
, mkFuncAggQueryFld
, argsWithoutSessionArgument
) where

import qualified Data.Sequence as Seq
Expand Down Expand Up @@ -35,14 +34,6 @@ input function_args {
}
-}

argsWithoutSessionArgument
:: Maybe SessionArgument
-> Seq.Seq FunctionArg
-> Seq.Seq FunctionArg
argsWithoutSessionArgument Nothing = id
argsWithoutSessionArgument (Just sessArg) =
Seq.filter (\arg -> Just (saName sessArg) /= faName arg)

procFuncArgs
:: Seq.Seq FunctionArg
-> (FunctionArg -> Text -> a) -> [a]
Expand All @@ -63,8 +54,7 @@ mkFuncArgsInp funcInfo =
bool (Just inpObj) Nothing $ null funcArgs
where
funcName = fiName funcInfo
funcArgs = argsWithoutSessionArgument (fiSessionVarArg funcInfo)
(fiInputArgs funcInfo)
funcArgs = fiInputArgs funcInfo
funcArgsTy = mkFuncArgsTy funcName

inpObj = mkHsraInpTyInfo Nothing funcArgsTy $
Expand Down
5 changes: 4 additions & 1 deletion server/src-lib/Hasura/RQL/DDL/Schema/Function.hs
Expand Up @@ -120,9 +120,12 @@ mkFunctionInfo qf config rawFuncInfo = do
maybeSessArg <- resolveSessionArgument

let funcArgsSeq = Seq.fromList functionArgs
removeSessArg sessArg = flip Seq.filter funcArgsSeq $
\arg -> Just (saName sessArg) /= faName arg
funcArgsSeqWithoutSessArg = maybe funcArgsSeq removeSessArg maybeSessArg
dep = SchemaDependency (SOTable retTable) DRTable
retTable = QualifiedObject retSn (TableName retN)
return $ FunctionInfo qf systemDefined funTy funcArgsSeq maybeSessArg retTable [dep] descM
pure $ FunctionInfo qf systemDefined funTy funcArgsSeqWithoutSessArg maybeSessArg retTable [dep] descM

validateFunctionArgNames = do
let argNames = mapMaybe faName functionArgs
Expand Down

0 comments on commit 24aceda

Please sign in to comment.