Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
This module provides common building blocks for composing Schema Parsers used in the schema of Update Mutations.
Synopsis
- data UpdateOperator b r m n op = UpdateOperator {
- updateOperatorApplicableColumn :: ColumnInfo b -> Bool
- updateOperatorParser :: GQLNameIdentifier -> TableName b -> NonEmpty (ColumnInfo b) -> SchemaT r m (InputFieldsParser n (HashMap (Column b) op))
- buildUpdateOperators :: forall b r m n op. MonadBuildSchema b r m n => HashMap (Column b) op -> [UpdateOperator b r m n op] -> TableInfo b -> SchemaT r m (InputFieldsParser n (HashMap (Column b) op))
- presetColumns :: UpdPermInfo b -> HashMap (Column b) (UnpreparedValue b)
- updateOperator :: forall n r m b a. MonadBuildSchema b r m n => GQLNameIdentifier -> GQLNameIdentifier -> GQLNameIdentifier -> (ColumnInfo b -> SchemaT r m (Parser 'Both n a)) -> NonEmpty (ColumnInfo b) -> Description -> Description -> SchemaT r m (InputFieldsParser n (HashMap (Column b) a))
- setOp :: forall b n r m. MonadBuildSchema b r m n => UpdateOperator b r m n (UnpreparedValue b)
- incOp :: forall b m n r. MonadBuildSchema b r m n => UpdateOperator b r m n (UnpreparedValue b)
Documentation
data UpdateOperator b r m n op Source #
UpdateOperator b m n op
represents one single update operator for a
backend b
.
The type variable op
is the backend-specific data type that represents
update operators, typically in the form of a sum-type with an
UnpreparedValue b
in each constructor.
The UpdateOperator b m n
is a Functor
. There exist building blocks of
common update operators (such as setOp
, etc.) which have op ~
UnpreparedValue b
. The Functor instance lets you wrap the generic update
operators in backend-specific tags.
UpdateOperator | |
|
Instances
(Functor m, Functor n) => Functor (UpdateOperator b r m n) Source # | |
Defined in Hasura.GraphQL.Schema.Update fmap :: (a -> b0) -> UpdateOperator b r m n a -> UpdateOperator b r m n b0 # (<$) :: a -> UpdateOperator b r m n b0 -> UpdateOperator b r m n a # |
:: forall b r m n op. MonadBuildSchema b r m n | |
=> HashMap (Column b) op | Columns with |
-> [UpdateOperator b r m n op] | Update operators to include in the Schema |
-> TableInfo b | |
-> SchemaT r m (InputFieldsParser n (HashMap (Column b) op)) |
The top-level component for building update operators parsers.
- It implements the
preset
functionality from Update Permissions (see <https://hasura.io/docs/latest/graphql/core/auth/authorization/permission-rules.html#column-presets Permissions user docs>). Use thepresetColumns
function to extract those from the update permissions. - It validates that that the update fields parsed are sound when taken as a whole, i.e. that some changes are actually specified (either in the mutation query text or in update preset columns) and that each column is only used in one operator.
presetColumns :: UpdPermInfo b -> HashMap (Column b) (UnpreparedValue b) Source #
The columns that have preset
definitions applied to them. (see
<https://hasura.io/docs/latest/graphql/core/auth/authorization/permission-rules.html#column-presets
Permissions user docs>)
updateOperator :: forall n r m b a. MonadBuildSchema b r m n => GQLNameIdentifier -> GQLNameIdentifier -> GQLNameIdentifier -> (ColumnInfo b -> SchemaT r m (Parser 'Both n a)) -> NonEmpty (ColumnInfo b) -> Description -> Description -> SchemaT r m (InputFieldsParser n (HashMap (Column b) a)) Source #
Construct a parser for a single update operator.
updateOperator _ "op" fp MkOp ["col1","col2"]
gives a parser that accepts
objects in the shape of:
op: { col1: "x", col2: "y" }
And (morally) parses into values:
HashMap.fromList [("col1", MkOp (fp "x")), ("col2", MkOp (fp "y"))]
setOp :: forall b n r m. MonadBuildSchema b r m n => UpdateOperator b r m n (UnpreparedValue b) Source #
incOp :: forall b m n r. MonadBuildSchema b r m n => UpdateOperator b r m n (UnpreparedValue b) Source #