Skip to content

Commit fa9077f

Browse files
committed
Add support for fine-grained dependency tracking to Incremental
1 parent 89af4ae commit fa9077f

34 files changed

+942
-396
lines changed

server/graphql-engine.cabal

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ library
9191
, http-client-tls
9292
, profunctors
9393
, deepseq
94+
, dependent-map >=0.2.4 && <0.4
95+
, dependent-sum >=0.4 && <0.5
9496

9597
-- `these >=1` is split into several different packages, but our current stack
9698
-- resolver has `these <1`; when we upgrade we just need to add an extra
@@ -232,7 +234,12 @@ library
232234

233235
, Data.Aeson.Ordered
234236

235-
other-modules: Hasura.Server.Auth.JWT
237+
other-modules: Hasura.Incremental.Select
238+
, Hasura.Incremental.Internal.Cache
239+
, Hasura.Incremental.Internal.Dependency
240+
, Hasura.Incremental.Internal.Rule
241+
242+
, Hasura.Server.Auth.JWT
236243
, Hasura.Server.Middleware
237244
, Hasura.Server.Cors
238245
, Hasura.Server.CheckUpdates

server/src-lib/Control/Arrow/Extended.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ module Control.Arrow.Extended
1313
, (>->)
1414
, (<-<)
1515
, dup
16+
, bothA
17+
, orA
1618

1719
, foldlA'
1820
, traverseA_
@@ -52,6 +54,17 @@ dup :: (Arrow arr) => arr a (a, a)
5254
dup = arr \x -> (x, x)
5355
{-# INLINE dup #-}
5456

57+
bothA :: (Arrow arr) => arr a b -> arr (a, a) (b, b)
58+
bothA f = f *** f
59+
{-# INLINE bothA #-}
60+
61+
orA :: (ArrowChoice arr) => arr a Bool -> arr b Bool -> arr (a, b) Bool
62+
orA f g = proc (a, b) -> do
63+
c <- f -< a
64+
if c then returnA -< True else g -< b
65+
{-# INLINABLE orA #-}
66+
{-# RULES "orA/arr" forall f g. arr f `orA` arr g = arr (f `orA` g) #-}
67+
5568
-- | 'foldl'' lifted to arrows. See also Note [Weird control operator types].
5669
foldlA' :: (ArrowChoice arr, Foldable t) => arr (e, (b, (a, s))) b -> arr (e, (b, (t a, s))) b
5770
foldlA' f = arr (\(e, (v, (xs, s))) -> (e, (v, (toList xs, s)))) >>> go where

server/src-lib/Control/Arrow/Trans.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ module Control.Arrow.Trans
1818
, WriterA(WriterA, runWriterA)
1919
) where
2020

21-
import Prelude hiding ((.), id)
21+
import Prelude hiding (id, (.))
2222

23-
import Control.Arrow
24-
import Control.Category
23+
import Control.Arrow
24+
import Control.Category
2525
import Control.Monad.Error.Class
2626
import Control.Monad.Reader.Class
2727
import Control.Monad.Writer.Class

server/src-lib/Hasura/GraphQL/Context.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Data.Aeson
66
import Data.Aeson.Casing
77
import Data.Aeson.TH
88
import Data.Has
9+
import Hasura.Incremental (Cacheable)
910
import Language.Haskell.TH.Syntax (Lift)
1011

1112
import qualified Data.HashMap.Strict as Map
@@ -90,6 +91,7 @@ data TableCustomRootFields
9091
, _tcrfDelete :: !(Maybe G.Name)
9192
} deriving (Show, Eq, Lift, Generic)
9293
instance NFData TableCustomRootFields
94+
instance Cacheable TableCustomRootFields
9395
$(deriveToJSON (aesonDrop 5 snakeCase){omitNothingFields=True} ''TableCustomRootFields)
9496

9597
instance FromJSON TableCustomRootFields where

0 commit comments

Comments
 (0)