graphql-engine-1.0.0: GraphQL API over Postgres
Safe HaskellNone
LanguageHaskell2010

Hasura.GraphQL.Schema.Update

Description

This module provides common building blocks for composing Schema Parsers used in the schema of Update Mutations.

Synopsis

Documentation

data UpdateOperator b 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.

Instances

Instances details
(Functor m, Functor n) => Functor (UpdateOperator b m n) Source # 
Instance details

Defined in Hasura.GraphQL.Schema.Update

Methods

fmap :: (a -> b0) -> UpdateOperator b m n a -> UpdateOperator b m n b0 #

(<$) :: a -> UpdateOperator b m n b0 -> UpdateOperator b m n a #

buildUpdateOperators Source #

Arguments

:: forall b r m n op. MonadBuildSchema b r m n 
=> HashMap (Column b) op

Columns with preset expressions

-> [UpdateOperator b m n op]

Update operators to include in the Schema

-> TableInfo b 
-> m (InputFieldsParser n (HashMap (Column b) op)) 

The top-level component for building update operators parsers.

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>)

runUpdateOperator :: forall b r m n op. MonadBuildSchema b r m n => TableInfo b -> UpdateOperator b m n op -> m (Maybe (InputFieldsParser n (HashMap (Column b) op))) Source #

Produce an InputFieldsParser from an UpdateOperator, but only if the operator applies to the table (i.e., it admits a non-empty column set).

mergeDisjoint :: forall b m t. (Backend b, MonadParse m) => [HashMap (Column b) t] -> m (HashMap (Column b) t) Source #

Merge the results of parsed update operators. Throws an error if the same column has been specified in multiple operators.

updateOperator :: forall n r m b a. (MonadParse n, MonadReader r m, Has MkTypename r, Has NamingCase r, Backend b) => GQLNameIdentifier -> GQLNameIdentifier -> GQLNameIdentifier -> (ColumnInfo b -> m (Parser 'Both n a)) -> NonEmpty (ColumnInfo b) -> Description -> Description -> 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:

M.fromList [("col1", MkOp (fp "x")), ("col2", MkOp (fp "y"))]

updateTable Source #

Arguments

:: forall b r m n. (MonadBuildSchema b r m n, AggregationPredicatesSchema b, BackendTableSelectSchema b) 
=> InputFieldsParser n (BackendUpdate b (UnpreparedValue b))

backend-specific data needed to perform an update mutation

-> Scenario 
-> SourceInfo b

table source

-> TableInfo b

table info

-> Name

field display name

-> Maybe Description

field description, if any

-> m (Maybe (FieldParser n (AnnotatedUpdateG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)))) 

Construct a root field, normally called update_tablename, that can be used to update rows in a DB table specified by filters. Only returns a parser if there are columns the user is allowed to update; otherwise returns Nothing.

updateTableByPk Source #

Arguments

:: forall b r m n. MonadBuildSchema b r m n 
=> BackendTableSelectSchema b 
=> InputFieldsParser n (BackendUpdate b (UnpreparedValue b))

backend-specific data needed to perform an update mutation

-> Scenario 
-> SourceInfo b

table source

-> TableInfo b

table info

-> Name

field display name

-> Maybe Description

field description, if any

-> m (Maybe (FieldParser n (AnnotatedUpdateG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b)))) 

Construct a root field, normally called update_tablename_by_pk, that can be used to update a single in a DB table, specified by primary key. Only returns a parser if there are columns the user is allowed to update and if the user has select permissions on all primary keys; otherwise returns Nothing.