graphql-engine/server/src-lib/Hasura/GraphQL/Schema/Mutation/Delete.hs

36 lines
1001 B
Haskell
Raw Normal View History

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
-}
mkDelMutFld :: Maybe G.Name -> QualifiedTable -> ObjFldInfo
mkDelMutFld mCustomName tn =
mkHsraObjFldInfo (Just desc) fldName (fromInpValL [filterArg]) $
G.toGT $ mkMutRespTy tn
where
desc = G.Description $ "delete data from the table: " <>> tn
defFldName = "delete_" <> qualObjectToName tn
fldName = fromMaybe defFldName mCustomName
filterArgDesc = "filter the rows which have to be deleted"
filterArg =
InpValInfo (Just filterArgDesc) "where" Nothing $ G.toGT $
G.toNT $ mkBoolExpTy tn