Skip to content

Commit b167120

Browse files
jberrymanhasura-bot
authored andcommitted
server: add explicit export lists in OSS server and enforce with warning
We'll see if this improves compile times at all, but I think it's worth doing as at least the most minimal form of module documentation. This was accomplished by first compiling everything with -ddump-minimal-imports, and then a bunch of scripting (with help from ormolu) **EDIT** it doesn't seem to improve CI compile times but the noise floor is high as it looks like we're not caching library dependencies anymore PR-URL: hasura/graphql-engine-mono#2730 GitOrigin-RevId: 667eb8d
1 parent a886da2 commit b167120

111 files changed

Lines changed: 1575 additions & 278 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎server/graphql-engine.cabal‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ common common-all
4040
-Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints
4141
-- This is just to keep compile-times in check and might be adjusted later (See mono #2610):
4242
-fmax-simplifier-iterations=2
43+
-- Insisting on export lists might help with compile times, and help to document modules:
44+
-Wmissing-export-lists
4345

4446
if flag(developer)
4547
cpp-options: -DDeveloperAPIs

‎server/src-lib/Control/Monad/Trans/Managed.hs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
module Control.Monad.Trans.Managed where
1+
module Control.Monad.Trans.Managed
2+
( ManagedT (..),
3+
allocate,
4+
allocate_,
5+
lowerManagedT,
6+
hoistManagedTReaderT,
7+
)
8+
where
29

310
import Control.Concurrent qualified as C
411
import Control.Exception.Lifted (bracket, bracket_)

‎server/src-lib/Hasura/App.hs‎

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,39 @@
11
{-# LANGUAGE UndecidableInstances #-}
22

3-
module Hasura.App where
3+
module Hasura.App
4+
( ExitCode (DatabaseMigrationError, DowngradeProcessError, MetadataCleanError, MetadataExportError, SchemaCacheInitError),
5+
ExitException (ExitException),
6+
GlobalCtx (GlobalCtx, _gcDefaultPostgresConnInfo, _gcHttpManager, _gcMetadataDbConnInfo),
7+
Loggers (..),
8+
PGMetadataStorageAppT (runPGMetadataStorageAppT),
9+
ServeCtx (ServeCtx, _scLoggers, _scMetadataDbPool, _scShutdownLatch),
10+
ShutdownLatch,
11+
accessDeniedErrMsg,
12+
flushLogger,
13+
getCatalogStateTx,
14+
initGlobalCtx,
15+
initialiseServeCtx,
16+
migrateCatalogSchema,
17+
mkLoggers,
18+
mkPGLogger,
19+
newShutdownLatch,
20+
notifySchemaCacheSyncTx,
21+
parseArgs,
22+
printErrExit,
23+
printErrJExit,
24+
printJSON,
25+
printYaml,
26+
readTlsAllowlist,
27+
resolvePostgresConnInfo,
28+
runHGEServer,
29+
setCatalogStateTx,
30+
shutdownGracefully,
31+
32+
-- * Exported for testing
33+
mkHGEServer,
34+
mkPgSourceResolver,
35+
)
36+
where
437

538
import Control.Concurrent.Async.Lifted.Safe qualified as LA
639
import Control.Concurrent.Extended qualified as C
@@ -63,7 +96,6 @@ import Hasura.RQL.DDL.Schema.Cache.Common
6396
import Hasura.RQL.DDL.Schema.Catalog
6497
import Hasura.RQL.Types
6598
import Hasura.RQL.Types.Eventing.Backend
66-
import Hasura.RQL.Types.Run
6799
import Hasura.SQL.AnyBackend qualified as AB
68100
import Hasura.Server.API.Query (requiresAdmin)
69101
import Hasura.Server.App
@@ -936,15 +968,6 @@ mkHGEServer setupHook env ServeOptions {..} ServeCtx {..} initTime postPollHook
936968
C.sleep (5) -- sleep for 5 seconds and then repeat
937969
waitForProcessingAction l actionType processingEventsCountAction' shutdownAction (maxTimeout - (Seconds 5))
938970

939-
runAsAdmin ::
940-
HTTP.Manager ->
941-
ServerConfigCtx ->
942-
RunT m a ->
943-
m (Either QErr a)
944-
runAsAdmin httpManager serverConfigCtx m = do
945-
let runCtx = RunCtx adminUserInfo httpManager serverConfigCtx
946-
runExceptT $ peelRun runCtx m
947-
948971
instance (Monad m) => Tracing.HasReporter (PGMetadataStorageAppT m)
949972

950973
instance (Monad m) => HasResourceLimits (PGMetadataStorageAppT m) where

‎server/src-lib/Hasura/Backends/BigQuery/Connection.hs‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
{-# LANGUAGE NumericUnderscores #-}
22

3-
module Hasura.Backends.BigQuery.Connection where
3+
module Hasura.Backends.BigQuery.Connection
4+
( BigQueryProblem,
5+
resolveConfigurationInput,
6+
resolveConfigurationInputs,
7+
resolveConfigurationJson,
8+
runBigQuery,
9+
)
10+
where
411

512
import Control.Concurrent.MVar
613
import Control.Exception
@@ -10,7 +17,6 @@ import Crypto.PubKey.RSA.Types as Cry (Error)
1017
import Data.Aeson qualified as J
1118
import Data.Aeson.Casing qualified as J
1219
import Data.Aeson.TH qualified as J
13-
import Data.Bifunctor (bimap)
1420
import Data.ByteArray.Encoding qualified as BAE
1521
import Data.ByteString qualified as BS
1622
import Data.ByteString.Char8 qualified as B8
@@ -156,10 +162,6 @@ getAccessToken sa = do
156162
"iss" J..= _saClientEmail
157163
]
158164

159-
getServiceAccount :: MonadIO m => FilePath -> m (Either ServiceAccountProblem ServiceAccount)
160-
getServiceAccount serviceAccountFilePath =
161-
bimap ServiceAccountFileDecodeProblem id . J.eitherDecode' <$> liftIO (BL.readFile serviceAccountFilePath)
162-
163165
-- | Get a usable token. If the token has expired refresh it.
164166
getUsableToken :: MonadIO m => BigQuerySourceConfig -> m (Either TokenProblem TokenResp)
165167
getUsableToken BigQuerySourceConfig {_scServiceAccount, _scAccessTokenMVar} =

‎server/src-lib/Hasura/Backends/BigQuery/DDL/BoolExp.hs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
module Hasura.Backends.BigQuery.DDL.BoolExp where
1+
module Hasura.Backends.BigQuery.DDL.BoolExp
2+
( parseBoolExpOperations,
3+
)
4+
where
25

36
import Data.Aeson qualified as J
47
import Data.HashMap.Strict qualified as Map

‎server/src-lib/Hasura/Backends/BigQuery/Instances/API.hs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-# OPTIONS_GHC -fno-warn-orphans #-}
22

3-
module Hasura.Backends.BigQuery.Instances.API where
3+
module Hasura.Backends.BigQuery.Instances.API () where
44

55
import Hasura.Prelude
66
import Hasura.SQL.Backend

‎server/src-lib/Hasura/Backends/BigQuery/Instances/Metadata.hs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-# OPTIONS_GHC -fno-warn-orphans #-}
22

3-
module Hasura.Backends.BigQuery.Instances.Metadata where
3+
module Hasura.Backends.BigQuery.Instances.Metadata () where
44

55
import Hasura.Backends.BigQuery.DDL qualified as BigQuery
66
import Hasura.RQL.Types.Metadata.Backend

‎server/src-lib/Hasura/Backends/BigQuery/Instances/Types.hs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-# OPTIONS_GHC -fno-warn-orphans #-}
22

3-
module Hasura.Backends.BigQuery.Instances.Types where
3+
module Hasura.Backends.BigQuery.Instances.Types () where
44

55
import Data.Aeson
66
import Hasura.Backends.BigQuery.Source qualified as BigQuery

‎server/src-lib/Hasura/Backends/BigQuery/Source.hs‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22
{-# LANGUAGE NoGeneralisedNewtypeDeriving #-}
33
{-# OPTIONS_GHC -fno-warn-orphans #-}
44

5-
module Hasura.Backends.BigQuery.Source where
5+
module Hasura.Backends.BigQuery.Source
6+
( BigQueryConnSourceConfig (..),
7+
BigQuerySourceConfig (..),
8+
ConfigurationInput (..),
9+
ConfigurationInputs (..),
10+
ConfigurationJSON (..),
11+
GoogleAccessToken (GoogleAccessToken),
12+
PKey (unPKey),
13+
ServiceAccount (..),
14+
TokenResp (..),
15+
)
16+
where
617

718
import Control.Concurrent.MVar
819
import Crypto.PubKey.RSA.Types qualified as Cry
@@ -60,9 +71,6 @@ instance J.FromJSON TokenResp where
6071
<$> o J..: "access_token"
6172
<*> o J..: "expires_in"
6273

63-
dummyTokenResp :: TokenResp
64-
dummyTokenResp = TokenResp (GoogleAccessToken "DUMMY") 0
65-
6674
data ServiceAccount = ServiceAccount
6775
{ _saClientEmail :: !Text,
6876
_saPrivateKey :: !PKey,

‎server/src-lib/Hasura/Backends/BigQuery/Types.hs‎

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,61 @@
11
{-# LANGUAGE DuplicateRecordFields #-}
22

33
-- | Types for Transact-SQL aka T-SQL; the language of SQL Server.
4-
module Hasura.Backends.BigQuery.Types where
4+
module Hasura.Backends.BigQuery.Types
5+
( Aggregate (..),
6+
Aliased (..),
7+
ArrayAgg (..),
8+
Base64,
9+
BigDecimal,
10+
Cardinality (..),
11+
ColumnName (ColumnName),
12+
Countable (..),
13+
Date (..),
14+
Datetime (..),
15+
Decimal,
16+
EntityAlias (..),
17+
Expression (..),
18+
FieldName (..),
19+
FieldOrigin (..),
20+
Float64,
21+
From (..),
22+
FunctionName (..),
23+
Geography (Geography),
24+
Int64 (Int64),
25+
Join (..),
26+
JoinProvenance (ArrayAggregateJoinProvenance, ArrayJoinProvenance, ObjectJoinProvenance, OrderByJoinProvenance),
27+
JoinSource (..),
28+
JsonPath (..),
29+
NullsOrder (..),
30+
Op (..),
31+
Order (..),
32+
OrderBy (..),
33+
Projection (..),
34+
Reselect (..),
35+
ScalarType (..),
36+
Select (..),
37+
TableName (..),
38+
Time (..),
39+
Timestamp (..),
40+
Top (..),
41+
Value (..),
42+
Where (..),
43+
WindowFunction (..),
44+
aggregateProjectionsFieldOrigin,
45+
doubleToBigDecimal,
46+
doubleToDecimal,
47+
doubleToFloat64,
48+
getGQLTableName,
49+
intToInt64,
50+
isComparableType,
51+
isNumType,
52+
parseScalarValue,
53+
projectionAlias,
54+
scalarTypeGraphQLName,
55+
textToUTCTime,
56+
utctimeToISO8601Text,
57+
)
58+
where
559

660
import Data.Aeson (FromJSON, FromJSONKey, ToJSON, ToJSONKey)
761
import Data.Aeson qualified as J

0 commit comments

Comments
 (0)