Safe Haskell | None |
---|---|
Language | Haskell2010 |
Make a plan for the data loader to execute (.Execute).
It will produce a graph of actions, to be executed by .Execute.
Synopsis
- data Ref = Ref {}
- data Select = Select {
- selectAggUnwrap :: Maybe Text
- selectFrom :: From
- selectGroupBy :: [FieldName]
- selectHaskellJoins :: [Join]
- selectOrderBy :: Maybe (NonEmpty OrderBy)
- selectProjections :: [Projection]
- selectRelationship :: Maybe Relationship
- selectWhere :: Where
- selectWantedFields :: Maybe [Text]
- selectSqlOffset :: Maybe Int
- selectSqlTop :: Top
- data Join = Join {
- leftRecordSet :: Ref
- rightRecordSet :: Ref
- joinRhsTop :: Top
- joinRhsOffset :: Maybe Int
- joinType :: JoinType
- joinFieldName :: Text
- wantedFields :: Maybe [Text]
- data Action
- data PlannedAction = PlannedAction {}
- data Relationship = Relationship {}
- newtype FieldName = FieldName Text
- data HeadAndTail = HeadAndTail {}
- data PlanState = PlanState {
- actions :: Seq PlannedAction
- counter :: Int
- newtype Plan a = Plan {}
- toFieldName :: FieldName -> FieldName
- joinAliasName :: EntityAlias -> Text
- selectFromName :: From -> Text
- runPlan :: Plan r -> (r, [PlannedAction])
- planSelectHeadAndTail :: Maybe Relationship -> Maybe Text -> Select -> Plan HeadAndTail
- planJoin :: Ref -> Join -> Plan Ref
- tell :: PlannedAction -> Plan ()
- generate :: Text -> Plan Ref
- actionsForest :: (Graph -> Graph) -> [PlannedAction] -> Forest PlannedAction
- selectQuery :: Select -> Select
- fromSelect :: Maybe Relationship -> Maybe Text -> Select -> Select
Documentation
A reference to a result of loading a recordset from the database.
Instances
Eq Ref Source # | |
Ord Ref Source # | |
Show Ref Source # | |
Generic Ref Source # | |
Hashable Ref Source # | |
Defined in Hasura.Backends.MySQL.DataLoader.Plan | |
type Rep Ref Source # | |
Defined in Hasura.Backends.MySQL.DataLoader.Plan type Rep Ref = D1 ('MetaData "Ref" "Hasura.Backends.MySQL.DataLoader.Plan" "graphql-engine-1.0.0-inplace" 'False) (C1 ('MetaCons "Ref" 'PrefixI 'True) (S1 ('MetaSel ('Just "idx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Int) :*: S1 ('MetaSel ('Just "text") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 Text))) |
A almost-the-same version of Select from Types.Internal, except with some fields used for planning and executing.
Select | |
|
An join action.
Join | |
|
An action that the executor will perform. Either pull data from the database directly via a select, or join two other actions' record sets together.
data PlannedAction Source #
An action planned, with a unique reference. I.e. the action
performed yields a result stored at reference ref
.
Instances
Show PlannedAction Source # | |
Defined in Hasura.Backends.MySQL.DataLoader.Plan showsPrec :: Int -> PlannedAction -> ShowS # show :: PlannedAction -> String # showList :: [PlannedAction] -> ShowS # |
data Relationship Source #
A relationship lets the executor insert on-the-fly WHERE fkey1=fkey2 for relationships. These can only be inserted on-the-fly and aren't known at the time of planning, because the keys come from the left-hand-side table for a join.
Instances
Show Relationship Source # | |
Defined in Hasura.Backends.MySQL.DataLoader.Plan showsPrec :: Int -> Relationship -> ShowS # show :: Relationship -> String # showList :: [Relationship] -> ShowS # |
Just a wrapper to clarify some types. It's different from the MySQL.FieldName because it doesn't care about schemas: schemas aren't returned in recordsets from the database.
FieldName Text |
Instances
Eq FieldName Source # | |
Ord FieldName Source # | |
Defined in Hasura.Backends.MySQL.DataLoader.Plan | |
Show FieldName Source # | |
IsString FieldName Source # | |
Defined in Hasura.Backends.MySQL.DataLoader.Plan fromString :: String -> FieldName # | |
Hashable FieldName Source # | |
Defined in Hasura.Backends.MySQL.DataLoader.Plan | |
FromJSON FieldName Source # | |
Defined in Hasura.Backends.MySQL.DataLoader.Plan parseJSON :: Value -> Parser FieldName parseJSONList :: Value -> Parser [FieldName] | |
ToJSONKey FieldName Source # | |
Defined in Hasura.Backends.MySQL.DataLoader.Plan toJSONKey :: ToJSONKeyFunction FieldName toJSONKeyList :: ToJSONKeyFunction [FieldName] |
data HeadAndTail Source #
The reason for this is subtle. Read this documentation. For each join on a select (see above, there is a list), we split that out into three jobs:
- One job for the left hand side (i.e. the select).
- One job for the right hand side (i.e. the join).
- One job to join them (And in the darkness bind them...)
This is performed as a fold, like: foldM planJoin head joins
. A
nice linked-list or tree-like structure arises. The planner code
produces a graph out of this; so it's possible that some
parallelism can be achieved by running multiple jobs at once.
The "head" is the first, original select. The "tail" is the (indirectly) linked list of joins. That list may also be empty. In that case, the tail is simply the same as the head.
If the tail is different to the head, then we choose the tail, as it represents the joined up version of both. If they're the same, we take whichever.
We're simply accumulating a set of actions with this. The counter lets us generate unique refs.
toFieldName :: FieldName -> FieldName Source #
Note that we're intentionally discarding the table qualification.
joinAliasName :: EntityAlias -> Text Source #
selectFromName :: From -> Text Source #
Used for display purposes, not semantic content.
runPlan :: Plan r -> (r, [PlannedAction]) Source #
planSelectHeadAndTail :: Maybe Relationship -> Maybe Text -> Select -> Plan HeadAndTail Source #
See the documentation for HeadAndTail
.
planJoin :: Ref -> Join -> Plan Ref Source #
Given a left-hand-side table and a join spec, produce a single reference that refers to the composition of the two.
tell :: PlannedAction -> Plan () Source #
Write the planned action to the state, like a writer's tell
.
actionsForest :: (Graph -> Graph) -> [PlannedAction] -> Forest PlannedAction Source #
Graph the set of planned actions ready for execution in the correct order.
selectQuery :: Select -> Select Source #
Used by the executor to produce a plain old select that can be sent to the MySQL server.
fromSelect :: Maybe Relationship -> Maybe Text -> Select -> Select Source #
From a plain select, and possibly a parent/left-hand-side relationship, produce a select that is useful for execution.