graphql-engine/server/graphql-engine.cabal
Vladimir Ciobanu da8f6981d4 server: reduce the number of backend dispatches
Fixes https://github.com/hasura/graphql-engine-mono/issues/712

Main point of interest: the `Hasura.SQL.Backend` module.

This PR creates an `Exists` type indexed by indexed type and packed constraint while hiding all of its complexity by not exporting the constructor.

Existential constructors/types which are no longer (directly) existential:
- [X] BackendSourceInfo :: BackendSourceInfo
- [x] BackendSourceMetadata :: BackendSourceMetadata
- [x] MOSourceObjId :: MetadatObjId
- [x] SOSourceObj :: SchemaObjId
- [x] RFDB :: RootField
- [x] LQP :: LiveQueryPlan
- [x] ExecutionStep :: ExecStepDB

This PR also removes ALL usages of `Typeable.cast` from our codebase. We still need to derive `Typeable` in a few places in order to be able to derive `Data` in one place. I have not dug deeper to see why this is needed.

GitOrigin-RevId: bb47e957192e4bb0af4c4116aee7bb92f7983445
2021-03-15 13:03:55 +00:00

635 lines
24 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

cabal-version: 2.2
name: graphql-engine
version: 1.0.0
synopsis: GraphQL API over Postgres
homepage: https://www.hasura.io
license: Apache-2.0
author: Vamshi Surabhi
maintainer: vamshi@hasura.io
copyright: Hasura Inc.
category: Database
build-type: Simple
source-repository head
type: git
location: https://github.com/hasura/graphql-engine
flag developer
description: Enable support for development-only APIs
default: False
manual: True
flag profiling
description: Configures the project to be profiling-compatible
default: False
manual: True
common common-all
ghc-options:
-fmax-simplifier-iterations=20 -foptimal-applicative-do
-Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints
if flag(developer)
cpp-options: -DDeveloperAPIs
if flag(profiling)
cpp-options: -DPROFILING
default-language: Haskell2010
default-extensions:
ApplicativeDo
BangPatterns
BlockArguments
ConstraintKinds
DataKinds
DefaultSignatures
DeriveDataTypeable
DeriveFoldable
DeriveFunctor
DeriveGeneric
DeriveLift
DeriveTraversable
DerivingVia
EmptyCase
ExistentialQuantification
FlexibleContexts
FlexibleInstances
FunctionalDependencies
GADTs
GeneralizedNewtypeDeriving
InstanceSigs
LambdaCase
MultiParamTypeClasses
MultiWayIf
NamedFieldPuns
NoImplicitPrelude
OverloadedStrings
QuantifiedConstraints
QuasiQuotes
RankNTypes
RecordWildCards
RoleAnnotations
ScopedTypeVariables
StandaloneDeriving
TemplateHaskell
TupleSections
TypeApplications
TypeFamilies
TypeFamilyDependencies
TypeOperators
common common-exe
ghc-options:
-threaded -rtsopts
-- `-I0` disables idle GC. We do this in application code now. See 'ourIdleGC' for details.
-- `-T` is required to collect the stats we use in 'ourIdleGC'.
--
-- `-qn2` limits the parallel GC to at most 2 capabilities. This came up in #3354/#3394, as the
-- parallel GC was causing significant performance overhead. Folks in #ghc on freenode advised
-- limiting the parallel GC to 2 or 3 capabilities as a very conservative choice, since more
-- than that is highly unlikely to ever be helpful. More benchmarking would be useful to know if
-- this is the right decision. Its possible it would better to just turn it off completely.
--
-- `-kc8K` helps limit memory consumption in websockets (perhaps elsewhere) by making the
-- cost of a thread's first (and probably only) stack overflow less severe.
-- See:https://github.com/hasura/graphql-engine/issues/5190
--
-- `--disable-delayed-os-memory-return` seems to help lower reported residency, in particular
-- in situations where we seem to be dealing with haskell heap fragmentation. This is more a
-- workaround for limitations in monitoring tools than anything...
"-with-rtsopts=-N -I0 -T -qn2 -kc8K --disable-delayed-os-memory-return"
library
import: common-all
hs-source-dirs: src-lib
build-depends: base
, bifunctors
, witherable
, validation
, lifted-base
, pg-client
, http-conduit
, validation
, text
, text-builder >= 0.6
, vector-builder
, bytestring
, postgresql-libpq
, mtl
, aeson
, aeson-casing
, unordered-containers >= 0.2.12
, template-haskell
, hashable
, kan-extensions
, transformers
, transformers-base
, http-types
, attoparsec
, attoparsec-iso8601 >= 1.0
, time >= 1.9
, scientific
, Spock-core
, split
, optparse-applicative
, containers
, monad-control
, monad-time
, monad-validate
, fast-logger
, wai
, postgresql-binary
, process
, http-client-tls
, profunctors
, deepseq
, dependent-map >=0.4 && <0.5
, dependent-sum >=0.7.1 && <0.8
, exceptions
, these
, semialign
-- Encoder related
, uuid
, vector
, vector-builder
, binary
, base16-bytestring
-- Logging related
, network
, byteorder
-- for parsing RSA keys
, cryptonite
-- for jwt verification
, jose
, pem
, x509
, asn1-encoding
, asn1-types
-- Server related
, warp
, th-lift-instances
, lens
-- GraphQL related
, graphql-parser >=0.2 && <0.3
-- URL parser related
, network-uri >=2.6.3.0 && <2.7
, uri-encode
-- String related
, case-insensitive
, text-conversions
-- Http client
, wreq
, http-client
-- ordered map
, insert-ordered-containers
-- Parsing SemVer
, semver
-- Templating
, mustache
, file-embed
, shakespeare >= 2.0.22
--
, data-has
-- for src-exec
, yaml
, template-haskell >= 2.11
-- websockets interface related
, websockets
, wai-websockets
, stm
, stm-containers
, list-t
, async
, lifted-async
, immortal < 0.3
-- logging related
, base64-bytestring >= 1.0
, auto-update
-- regex related
, regex-tdfa >=1.3.1 && <1.4
-- pretty printer
, ansi-wl-pprint
, pretty-simple
-- for capturing various metrics
, ekg-core
, ekg-json
-- metrics for CI integration
, ci-info
-- serve static files
, filepath >= 1.4
, mime-types >= 0.1
-- for handling posix signals for graceful shutdown
, unix
-- HTTP compression
, zlib
-- caching
, psqueues >= 0.2
-- testing
, QuickCheck
, generic-arbitrary
, quickcheck-instances
, directory
, random
, mmorph
, http-api-data
, lens-aeson
, safe
, semigroups >= 0.19.1
-- scheduled triggers
, cron >= 0.6.2
-- needed for deriving via
, semigroups >= 0.19
-- mssql support
, odbc
, resource-pool
if !flag(profiling)
build-depends:
-- 0.6.1 is supposedly not okay for ghc 8.6:
-- https://github.com/nomeata/ghc-heap-view/issues/27
ghc-heap-view
exposed-modules: Control.Arrow.Extended
, Control.Arrow.Trans
, Control.Concurrent.Extended
, Control.Lens.Extended
, Control.Monad.Stateless
, Control.Monad.Trans.Managed
, Control.Monad.Unique
, Data.Aeson.Extended
, Data.Aeson.Ordered
, Data.Environment
, Data.HashMap.Strict.Extended
, Data.HashMap.Strict.InsOrd.Extended
, Data.List.Extended
, Data.Parser.CacheControl
, Data.Parser.Expires
, Data.Parser.JSONPath
, Data.Sequence.NonEmpty
, Data.TByteString
, Data.Text.Extended
, Data.Text.NonEmpty
, Data.Time.Clock.Units
, Data.URL.Template
, Hasura.App
, Hasura.Metadata.Class
, Hasura.Backends.Postgres.Connection
, Hasura.Backends.Postgres.DDL
, Hasura.Backends.Postgres.DDL.BoolExp
, Hasura.Backends.Postgres.DDL.Field
, Hasura.Backends.Postgres.DDL.Function
, Hasura.Backends.Postgres.DDL.RunSQL
, Hasura.Backends.Postgres.DDL.Source
, Hasura.Backends.Postgres.DDL.Table
, Hasura.Backends.Postgres.Execute.LiveQuery
, Hasura.Backends.Postgres.Execute.Mutation
, Hasura.Backends.Postgres.Execute.RemoteJoin
, Hasura.Backends.Postgres.Execute.Types
, Hasura.Backends.Postgres.Instances.Execute
, Hasura.Backends.Postgres.Instances.Schema
, Hasura.Backends.Postgres.Instances.Transport
, Hasura.Backends.Postgres.Instances.Types
, Hasura.Backends.Postgres.SQL.DML
, Hasura.Backends.Postgres.SQL.Error
, Hasura.Backends.Postgres.SQL.Rewrite
, Hasura.Backends.Postgres.SQL.Types
, Hasura.Backends.Postgres.SQL.Value
, Hasura.Backends.Postgres.Translate.BoolExp
, Hasura.Backends.Postgres.Translate.Column
, Hasura.Backends.Postgres.Translate.Delete
, Hasura.Backends.Postgres.Translate.Insert
, Hasura.Backends.Postgres.Translate.Mutation
, Hasura.Backends.Postgres.Translate.Returning
, Hasura.Backends.Postgres.Translate.Select
, Hasura.Backends.Postgres.Translate.Types
, Hasura.Backends.Postgres.Translate.Update
, Hasura.Backends.MSSQL.Connection
, Hasura.Backends.MSSQL.DDL
, Hasura.Backends.MSSQL.DDL.RunSQL
, Hasura.Backends.MSSQL.DDL.Source
, Hasura.Backends.MSSQL.DDL.BoolExp
, Hasura.Backends.MSSQL.FromIr
, Hasura.Backends.MSSQL.Instances.Execute
, Hasura.Backends.MSSQL.Instances.Schema
, Hasura.Backends.MSSQL.Instances.Transport
, Hasura.Backends.MSSQL.Instances.Types
, Hasura.Backends.MSSQL.Meta
, Hasura.Backends.MSSQL.Plan
, Hasura.Backends.MSSQL.ToQuery
, Hasura.Backends.MSSQL.Types
, Hasura.Backends.MSSQL.Types.Instances
, Hasura.Backends.MSSQL.Types.Internal
-- Exposed for benchmark:
, Hasura.Cache.Bounded
, Hasura.Logging
, Hasura.HTTP
, Hasura.Incremental
, Hasura.Server.App
, Hasura.Server.Auth
, Hasura.Server.Init
, Hasura.Server.Init.Config
, Hasura.Server.API.Query
, Hasura.Server.API.V2Query
, Hasura.Server.API.Metadata
, Hasura.Server.Utils
, Hasura.Server.Version
, Hasura.Server.Logging
, Hasura.Server.Migrate
, Hasura.Server.Compression
, Hasura.Server.Types
, Hasura.Server.API.PGDump
, Hasura.Server.Rest
, Hasura.Prelude
, Hasura.EncJSON
, Hasura.GraphQL.Execute.Query
, Hasura.GraphQL.Logging
, Hasura.Incremental.Select
, Hasura.RQL.DML.Select
, Hasura.RQL.Types.Run
, Hasura.Session
-- exposed for Pro
, Hasura.Server.API.Config
, Hasura.Server.Telemetry
-- Exposed for testing:
, Hasura.Server.Telemetry.Counters
, Hasura.Server.Auth.JWT
, Hasura.GC
, Hasura.Incremental.Internal.Cache
, Hasura.Incremental.Internal.Dependency
, Hasura.Incremental.Internal.Rule
, Hasura.Server.Auth.WebHook
, Hasura.Server.Middleware
, Hasura.Server.Cors
, Hasura.Server.CheckUpdates
, Hasura.Server.SchemaUpdate
, Hasura.Server.Migrate.Version
, Hasura.Server.Migrate.Internal
, Hasura.Server.Auth.JWT.Internal
, Hasura.Server.Auth.JWT.Logging
, Hasura.RQL.Instances
, Hasura.RQL.Types
, Hasura.RQL.Types.Action
, Hasura.RQL.Types.ApiLimit
, Hasura.RQL.Types.Backend
, Hasura.RQL.Types.Column
, Hasura.RQL.Types.Common
, Hasura.RQL.Types.ComputedField
, Hasura.RQL.Types.CustomTypes
, Hasura.RQL.Types.Endpoint
, Hasura.RQL.Types.Endpoint.Trie
, Hasura.RQL.Types.Error
, Hasura.RQL.Types.EventTrigger
, Hasura.RQL.Types.Function
, Hasura.RQL.Types.Metadata
, Hasura.RQL.Types.Metadata.Backend
, Hasura.RQL.Types.Metadata.Object
, Hasura.RQL.Types.Permission
, Hasura.RQL.Types.QueryCollection
, Hasura.RQL.Types.Relationship
, Hasura.RQL.Types.RemoteRelationship
, Hasura.RQL.Types.RemoteSchema
, Hasura.RQL.Types.ScheduledTrigger
, Hasura.RQL.Types.SchemaCache
, Hasura.RQL.Types.SchemaCache.Build
, Hasura.RQL.Types.SchemaCacheTypes
, Hasura.RQL.Types.Source
, Hasura.RQL.Types.Table
, Hasura.RQL.Types.InheritedRoles
, Hasura.RQL.DDL.Action
, Hasura.RQL.DDL.ApiLimit
, Hasura.RQL.DDL.ComputedField
, Hasura.RQL.DDL.CustomTypes
, Hasura.RQL.DDL.Deps
, Hasura.RQL.DDL.Endpoint
, Hasura.RQL.DDL.InheritedRoles
, Hasura.RQL.DDL.Headers
, Hasura.RQL.DDL.Metadata
, Hasura.RQL.DDL.Metadata.Generator
, Hasura.RQL.DDL.Metadata.Types
, Hasura.RQL.DDL.Permission
, Hasura.RQL.DDL.Permission.Internal
, Hasura.RQL.DDL.QueryCollection
, Hasura.RQL.DDL.Relationship
, Hasura.RQL.DDL.Relationship.Rename
, Hasura.RQL.DDL.RemoteRelationship
, Hasura.RQL.DDL.RemoteRelationship.Validate
, Hasura.RQL.DDL.RemoteSchema
, Hasura.RQL.DDL.RemoteSchema.Permission
, Hasura.RQL.DDL.Schema
, Hasura.RQL.DDL.Schema.Cache
, Hasura.RQL.DDL.Schema.Cache.Common
, Hasura.RQL.DDL.Schema.Cache.Dependencies
, Hasura.RQL.DDL.Schema.Cache.Fields
, Hasura.RQL.DDL.Schema.Cache.Permission
, Hasura.RQL.DDL.Schema.Catalog
, Hasura.RQL.DDL.Schema.LegacyCatalog
, Hasura.RQL.DDL.Schema.Common
, Hasura.RQL.DDL.Schema.Diff
, Hasura.RQL.DDL.Schema.Enum
, Hasura.RQL.DDL.Schema.Function
, Hasura.RQL.DDL.Schema.Rename
, Hasura.RQL.DDL.Schema.Table
, Hasura.RQL.DDL.Schema.Source
, Hasura.RQL.DDL.EventTrigger
, Hasura.RQL.DDL.ScheduledTrigger
, Hasura.RQL.DML.Count
, Hasura.RQL.DML.Delete
, Hasura.RQL.DML.Insert
, Hasura.RQL.DML.Internal
, Hasura.RQL.DML.Update
, Hasura.RQL.DML.Types
, Hasura.RQL.IR.BoolExp
, Hasura.RQL.IR.Delete
, Hasura.RQL.IR.Insert
, Hasura.RQL.IR.OrderBy
, Hasura.RQL.IR.RemoteJoin
, Hasura.RQL.IR.Returning
, Hasura.RQL.IR.Select
, Hasura.RQL.IR.Update
, Hasura.GraphQL.Context
, Hasura.GraphQL.Execute
, Hasura.GraphQL.Execute.Action
, Hasura.GraphQL.Execute.Action.Types
, Hasura.GraphQL.Execute.Backend
, Hasura.GraphQL.Execute.Common
, Hasura.GraphQL.Execute.Inline
, Hasura.GraphQL.Execute.Insert
, Hasura.GraphQL.Execute.LiveQuery.Explain
, Hasura.GraphQL.Execute.LiveQuery.Options
, Hasura.GraphQL.Execute.LiveQuery.Plan
, Hasura.GraphQL.Execute.LiveQuery.Poll
, Hasura.GraphQL.Execute.LiveQuery.State
, Hasura.GraphQL.Execute.LiveQuery.TMap
, Hasura.GraphQL.Execute.Mutation
, Hasura.GraphQL.Execute.Plan
, Hasura.GraphQL.Execute.Prepare
, Hasura.GraphQL.Execute.Remote
, Hasura.GraphQL.Execute.RemoteJoin
, Hasura.GraphQL.Execute.Resolve
, Hasura.GraphQL.Execute.Types
, Hasura.GraphQL.Explain
, Hasura.GraphQL.Parser
, Hasura.GraphQL.Parser.Class
, Hasura.GraphQL.Parser.Class.Parse
, Hasura.GraphQL.Parser.Collect
, Hasura.GraphQL.Parser.Column
, Hasura.GraphQL.Parser.Internal.Parser
, Hasura.GraphQL.Parser.Internal.Types
, Hasura.GraphQL.Parser.Monad
, Hasura.GraphQL.Parser.Schema
, Hasura.GraphQL.RemoteServer
, Hasura.GraphQL.Schema
, Hasura.GraphQL.Schema.Action
, Hasura.GraphQL.Schema.Backend
, Hasura.GraphQL.Schema.BoolExp
, Hasura.GraphQL.Schema.Build
, Hasura.GraphQL.Schema.Common
, Hasura.GraphQL.Schema.Introspect
, Hasura.GraphQL.Schema.Mutation
, Hasura.GraphQL.Schema.OrderBy
, Hasura.GraphQL.Schema.Postgres
, Hasura.GraphQL.Schema.Remote
, Hasura.GraphQL.Schema.Select
, Hasura.GraphQL.Schema.Table
, Hasura.GraphQL.Transport.Backend
, Hasura.GraphQL.Transport.HTTP
, Hasura.GraphQL.Transport.HTTP.Protocol
, Hasura.GraphQL.Transport.WebSocket
, Hasura.GraphQL.Transport.WebSocket.Protocol
, Hasura.GraphQL.Transport.WebSocket.Server
, Hasura.Eventing.HTTP
, Hasura.Eventing.EventTrigger
, Hasura.Eventing.ScheduledTrigger
, Hasura.Eventing.ScheduledTrigger.Types
, Hasura.Eventing.Common
, Data.GADT.Compare.Extended
, Data.Tuple.Extended
, Hasura.SQL.AnyBackend
, Hasura.SQL.Backend
, Hasura.SQL.GeoJSON
, Hasura.SQL.Time
, Hasura.SQL.Types
, Hasura.Tracing
, Network.HTTP.Client.Extended
, Network.URI.Extended
, Network.Wai.Extended
, Network.Wai.Handler.WebSockets.Custom
executable graphql-engine
import: common-all, common-exe
hs-source-dirs: src-exec
main-is: Main.hs
build-depends: base
, graphql-engine
, bytestring
, kan-extensions
, pg-client
, text
, text-conversions
, time
, unix
, ekg-core
test-suite graphql-engine-tests
import: common-all, common-exe
type: exitcode-stdio-1.0
build-depends:
aeson
, base
, bytestring
, containers
, graphql-engine
, hspec >=2.6.1 && <3
, hspec-core >=2.6.1 && <3
, hspec-expectations-lifted
, http-client
, http-types
, http-client-tls
, jose
, lens
, lifted-base
, kan-extensions
, monad-control
, mtl
, natural-transformation >=0.4 && <0.5
, optparse-applicative
, pg-client
, process
, QuickCheck
, text
, safe
, split
, time
, transformers-base
, unordered-containers
, text
, mmorph
hs-source-dirs: src-test
main-is: Main.hs
other-modules:
Data.Parser.CacheControlSpec
Data.Parser.URLTemplate
Data.Parser.JSONPathSpec
Data.TimeSpec
Data.NonNegativeIntSpec
Hasura.IncrementalSpec
Hasura.RQL.MetadataSpec
Hasura.RQL.Types.EndpointSpec
Hasura.Server.MigrateSpec
Hasura.Server.TelemetrySpec
Hasura.CacheBoundedSpec
Hasura.Server.AuthSpec
-- Benchmarks related to caching (e.g. the plan cache).
--
-- NOTE: Some of these are very slow and can only be reasonably run with `cache -n 1` for now.
benchmark cache
import: common-all, common-exe
type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs: src-bench-cache
build-depends: base
, criterion
, mwc-random
, mwc-probability
, vector
, deepseq
, graphql-engine
, split
, async
, text
, bytestring