Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 4669498

Browse files
committed
Add sub-command server to start an API + GraphQL server
1 parent 490e0d6 commit 4669498

File tree

7 files changed

+335
-12
lines changed

7 files changed

+335
-12
lines changed

stack.yaml

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
# ATTENTION: Also update the version in the Dockerfile
2-
resolver: lts-22.13
2+
resolver: lts-22.19
3+
34
packages:
45
- huzzy
56
- tasklite-core
67
# - tasklite-app
78

89
extra-deps:
910
- aeson-2.2.1.0
10-
# TODO: Upgrade after 0.7.x includes missing megaparsec dependency
11-
- simple-sql-parser-0.6.0
11+
- airgql-0.7.1.2
12+
- double-x-encoding-1.2.1
13+
- graphql-spice-1.0.2.0
14+
15+
- github: Airsequel/simple-sql-parser
16+
commit: 680f2b77c53fcc086dc7d5f498f764ad2235b828
1217

1318
- github: ad-si/iso8601-duration
1419
commit: 15822155a51831fbcd75a3bb5cb608a731a0461b
1520

1621
allow-newer: true
1722

23+
flags:
24+
aeson-pretty:
25+
lib-only: true
26+
27+
airgql:
28+
lib-only: true
29+
1830
# Build TaskLite in a container
1931
# docker:
2032
# repo: fpco/stack-build

stack.yaml.lock

+33-8
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,37 @@ packages:
1212
original:
1313
hackage: aeson-2.2.1.0
1414
- completed:
15-
hackage: simple-sql-parser-0.6.0@sha256:ce8f602fa81001287deb25af7b711fc45e1cdf36ff7702edde5dee2358f19a37,5580
15+
hackage: airgql-0.7.1.2@sha256:43e5f5d98391b4515a71489498a1a60e9e3baef6a7e23e74d3e45ef8ba3c5c92,6971
1616
pantry-tree:
17-
sha256: cd333c976b4b12425d0eed28749884551a4595dd249cc6d6b75c34e4ce7688cc
18-
size: 2752
17+
sha256: 3fbb535a536df207b8c3173c95406deaebf5cf931566cc79442b5fec3cefdd28
18+
size: 1722
1919
original:
20-
hackage: simple-sql-parser-0.6.0
20+
hackage: airgql-0.7.1.2
21+
- completed:
22+
hackage: double-x-encoding-1.2.1@sha256:9dfc5a74ad82f507a5adeeddc7e32545cde04d11716fc44cd9bd2160bb38fb4c,1813
23+
pantry-tree:
24+
sha256: 9d0d9316d3da245a690dabecee9fb1797a10e09344758e9b8e7f7cb2728b5c04
25+
size: 237
26+
original:
27+
hackage: double-x-encoding-1.2.1
28+
- completed:
29+
hackage: graphql-spice-1.0.2.0@sha256:97d22da8ec38342408bcd237e91e76ffcdad4f14df666f62b0b1ccba6bf39b87,2000
30+
pantry-tree:
31+
sha256: d60774d462c7c0af08c82b3f754e0ac49e598640e382c417e1809880192747cb
32+
size: 937
33+
original:
34+
hackage: graphql-spice-1.0.2.0
35+
- completed:
36+
name: simple-sql-parser
37+
pantry-tree:
38+
sha256: a7f399e93b6cb3056e43702b57ecda1a6a86dfdbeca4361ae3d2d27518ba4fe7
39+
size: 3846
40+
sha256: 5731c4471e011dede78b8f1d8812dd5eeb1c79024307f0b03f1855f9028e43e0
41+
size: 137333
42+
url: https://github.com/Airsequel/simple-sql-parser/archive/680f2b77c53fcc086dc7d5f498f764ad2235b828.tar.gz
43+
version: 0.6.1
44+
original:
45+
url: https://github.com/Airsequel/simple-sql-parser/archive/680f2b77c53fcc086dc7d5f498f764ad2235b828.tar.gz
2146
- completed:
2247
name: iso8601-duration
2348
pantry-tree:
@@ -31,7 +56,7 @@ packages:
3156
url: https://github.com/ad-si/iso8601-duration/archive/15822155a51831fbcd75a3bb5cb608a731a0461b.tar.gz
3257
snapshots:
3358
- completed:
34-
sha256: 6f0bea3ba5b07360f25bc886e8cff8d847767557a492a6f7f6dcb06e3cc79ee9
35-
size: 712905
36-
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/13.yaml
37-
original: lts-22.13
59+
sha256: e5cac927cf7ccbd52aa41476baa68b88c564ee6ddc3bc573dbf4210069287fe7
60+
size: 713340
61+
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/22/19.yaml
62+
original: lts-22.19

tasklite-core/package.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ library:
5050
source-dirs: source
5151
dependencies:
5252
- aeson
53+
- airgql
5354
- ansi-terminal
5455
- bytestring
5556
- cassava
@@ -76,6 +77,10 @@ library:
7677
- QuickCheck
7778
- quickcheck-instances
7879
- random
80+
- servant
81+
- servant-blaze
82+
- servant-multipart
83+
- servant-server
7984
- simple-sql-parser
8085
- sqlite-simple
8186
- sqlite-simple
@@ -86,7 +91,12 @@ library:
8691
- ulid
8792
- unix
8893
- vector
94+
- wai
95+
- wai-cors
96+
- wai-app-static
97+
- warp
8998
- yaml
99+
- wai-extra
90100

91101
executables:
92102
tasklite:

tasklite-core/source/Cli.hs

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import Protolude (
4545
)
4646
import Protolude qualified as P
4747

48+
import AirGQL.Config qualified as AirGQL
4849
import Control.Monad.Catch (catchAll)
4950
import Data.Aeson as Aeson (KeyValue ((.=)), encode, object)
5051
import Data.FileEmbed (embedStringFile, makeRelativeToProject)
@@ -214,6 +215,7 @@ import Lib (
214215
waitTasks,
215216
)
216217
import Migrations (runMigrations)
218+
import Server (startServer)
217219
import System.Environment (getProgName)
218220
import Utils (
219221
IdText,
@@ -337,6 +339,7 @@ data Command
337339
Alias Text (Maybe [Text])
338340
| Help
339341
| PrintConfig
342+
| StartServer
340343
| UlidToUtc Text
341344
| ExternalCommand Text (Maybe [Text])
342345
deriving (Show, Eq)
@@ -850,6 +853,11 @@ commandParser conf =
850853
<> command "config" (toParserInfo (pure PrintConfig)
851854
"Print current configuration of TaskLite")
852855

856+
<> command "server" (toParserInfo (pure StartServer)
857+
"Start an API server with several endpoints \
858+
\for data access and management \
859+
\(including a GraphQL endpoint powered by AirGQL)")
860+
853861
-- <> command "verify" (toParserInfo (pure Verify)
854862
-- "Verify the integrity of the database")
855863

@@ -1233,6 +1241,7 @@ executeCLiCommand conf now connection progName args = do
12331241
Version -> pure $ pretty versionSlug <> hardline
12341242
Help -> pure $ getHelpText progName conf
12351243
PrintConfig -> pure $ pretty conf
1244+
StartServer -> startServer AirGQL.defaultConfig conf
12361245
Alias alias _ -> pure $ aliasWarning alias
12371246
UlidToUtc ulid -> pure $ pretty $ ulid2utc ulid
12381247
ExternalCommand cmd argsMb -> handleExternalCommand conf cmd argsMb

0 commit comments

Comments
 (0)