graphql-engine/server/src-lib/Hasura/RQL/IR/Update.hs
Antoine Leblanc b9ee669ee1 Improve remote joins collect
### Description

This PR improves the `Collect` module by re-ordering the functions to make clear what is public API and what is internal implementation. Furthermore, it makes use of `traverseOf` and `traverseFields` to reduce duplication. To do so, it also introduces a few more lenses in the rest of the codebase, and uses this opportunity to harmonize some structures that were not following our naming convention.

While the diff is massive, a lot of it is just code moving around; the file is now divided into separate sections:
- entry points: IR types for which we want to run the collection
- internal monadic structure
- internal traversals: functions that do nothing but drill down further
- actual transformations: the three cases where we do actually have work to do: selection sets on which we do want to insert join columns, extract remote relationships... those functions are left unchanged by this PR
- internal helpers

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3863
GitOrigin-RevId: f7cbecfae9eed9737b62acfa5848bfcf9d4651f6
2022-03-10 06:18:48 +00:00

39 lines
1.0 KiB
Haskell

module Hasura.RQL.IR.Update
( AnnotatedUpdate,
AnnotatedUpdateG (..),
auTable,
auWhere,
auCheck,
auBackend,
auOutput,
auAllCols,
)
where
import Control.Lens.TH (makeLenses)
import Data.Kind (Type)
import Hasura.Prelude
import Hasura.RQL.IR.BoolExp
import Hasura.RQL.IR.Returning
import Hasura.RQL.Types.Backend
import Hasura.RQL.Types.Column
import Hasura.SQL.Backend
data AnnotatedUpdateG (b :: BackendType) (r :: Type) v = AnnotatedUpdateG
{ _auTable :: !(TableName b),
_auWhere :: !(AnnBoolExp b v, AnnBoolExp b v),
_auCheck :: !(AnnBoolExp b v),
-- | All the backend-specific data related to an update mutation
_auBackend :: BackendUpdate b v,
-- we don't prepare the arguments for returning
-- however the session variable can still be
-- converted as desired
_auOutput :: !(MutationOutputG b r v),
_auAllCols :: ![ColumnInfo b]
}
deriving (Functor, Foldable, Traversable)
type AnnotatedUpdate b = AnnotatedUpdateG b Void (SQLExpression b)
$(makeLenses ''AnnotatedUpdateG)