2019-08-09 12:19:17 +03:00
|
|
|
module Hasura.GraphQL.Schema.Mutation.Delete
|
|
|
|
( mkDelMutFld
|
|
|
|
) where
|
|
|
|
|
|
|
|
import qualified Language.GraphQL.Draft.Syntax as G
|
|
|
|
|
|
|
|
import Hasura.GraphQL.Schema.BoolExp
|
|
|
|
import Hasura.GraphQL.Schema.Common
|
|
|
|
import Hasura.GraphQL.Schema.Mutation.Common
|
|
|
|
import Hasura.GraphQL.Validate.Types
|
|
|
|
import Hasura.Prelude
|
|
|
|
import Hasura.SQL.Types
|
|
|
|
|
|
|
|
{-
|
|
|
|
|
|
|
|
delete_table(
|
|
|
|
where : table_bool_exp!
|
|
|
|
): table_mutation_response
|
|
|
|
|
|
|
|
-}
|
|
|
|
|
2019-09-19 07:47:36 +03:00
|
|
|
mkDelMutFld :: Maybe G.Name -> QualifiedTable -> ObjFldInfo
|
|
|
|
mkDelMutFld mCustomName tn =
|
2019-08-09 12:19:17 +03:00
|
|
|
mkHsraObjFldInfo (Just desc) fldName (fromInpValL [filterArg]) $
|
|
|
|
G.toGT $ mkMutRespTy tn
|
|
|
|
where
|
|
|
|
desc = G.Description $ "delete data from the table: " <>> tn
|
|
|
|
|
2019-09-19 07:47:36 +03:00
|
|
|
defFldName = "delete_" <> qualObjectToName tn
|
|
|
|
fldName = fromMaybe defFldName mCustomName
|
2019-08-09 12:19:17 +03:00
|
|
|
|
|
|
|
filterArgDesc = "filter the rows which have to be deleted"
|
|
|
|
filterArg =
|
|
|
|
InpValInfo (Just filterArgDesc) "where" Nothing $ G.toGT $
|
|
|
|
G.toNT $ mkBoolExpTy tn
|