mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-18 04:51:35 +03:00
24592a516b
* Pass environment variables around as a data structure, via @sordina * Resolving build error * Adding Environment passing note to changelog * Removing references to ILTPollerLog as this seems to have been reintroduced from a bad merge * removing commented-out imports * Language pragmas already set by project * Linking async thread * Apply suggestions from code review Use `runQueryTx` instead of `runLazyTx` for queries. * remove the non-user facing entry in the changelog Co-authored-by: Phil Freeman <paf31@cantab.net> Co-authored-by: Phil Freeman <phil@hasura.io> Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
42 lines
1.4 KiB
Haskell
42 lines
1.4 KiB
Haskell
module Hasura.GraphQL.Execute.LiveQuery.Options
|
|
( LiveQueriesOptions(..)
|
|
, BatchSize(..)
|
|
, RefetchInterval(..)
|
|
, mkLiveQueriesOptions
|
|
) where
|
|
|
|
import Hasura.Prelude
|
|
|
|
import qualified Data.Aeson as J
|
|
|
|
data LiveQueriesOptions
|
|
= LiveQueriesOptions
|
|
{ _lqoBatchSize :: !BatchSize
|
|
, _lqoRefetchInterval :: !RefetchInterval
|
|
} deriving (Show, Eq)
|
|
|
|
mkLiveQueriesOptions :: Maybe BatchSize -> Maybe RefetchInterval -> LiveQueriesOptions
|
|
mkLiveQueriesOptions batchSize refetchInterval = LiveQueriesOptions
|
|
{ _lqoBatchSize = fromMaybe (BatchSize 100) batchSize
|
|
, _lqoRefetchInterval = fromMaybe (RefetchInterval 1) refetchInterval
|
|
}
|
|
|
|
instance J.ToJSON LiveQueriesOptions where
|
|
toJSON (LiveQueriesOptions batchSize refetchInterval) =
|
|
J.object [ "batch_size" J..= batchSize
|
|
, "refetch_delay" J..= refetchInterval
|
|
]
|
|
|
|
instance J.FromJSON LiveQueriesOptions where
|
|
parseJSON = J.withObject "live query options" \o ->
|
|
LiveQueriesOptions <$> o J..: "batch_size"
|
|
<*> o J..: "refetch_delay"
|
|
|
|
newtype BatchSize = BatchSize { unBatchSize :: Int }
|
|
deriving (Show, Eq, J.ToJSON, J.FromJSON)
|
|
|
|
-- TODO this is treated as milliseconds in fromEnv and as seconds in ToJSON.
|
|
-- ideally this would have e.g. ... unRefetchInterval :: Milliseconds
|
|
newtype RefetchInterval = RefetchInterval { unRefetchInterval :: DiffTime }
|
|
deriving (Show, Eq, J.ToJSON, J.FromJSON)
|