Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
b19e86ef
Commit
b19e86ef
authored
Oct 20, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graphql] NUTCTime for gql serialization
parent
79ff0460
Pipeline
#1990
failed with stage
in 10 minutes and 24 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
UTCTime.hs
src/Gargantext/Utils/UTCTime.hs
+33
-0
No files found.
src/Gargantext/Utils/UTCTime.hs
0 → 100644
View file @
b19e86ef
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeFamilies #-}
module
Gargantext.Utils.UTCTime
where
import
Data.Aeson
(
FromJSON
,
ToJSON
)
import
Data.Either
(
Either
(
..
))
import
Data.Morpheus.Kind
(
SCALAR
)
import
Data.Morpheus.Types
(
GQLType
(
..
),
DecodeScalar
(
..
),
EncodeScalar
(
..
))
import
qualified
Data.Morpheus.Types
as
DMT
import
Data.Swagger
(
ToSchema
)
import
qualified
Data.Text
as
T
import
Data.Time
(
UTCTime
)
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
import
Text.Read
(
readEither
)
newtype
NUTCTime
=
NUTCTime
UTCTime
deriving
(
Eq
,
Show
,
Generic
)
instance
DecodeScalar
NUTCTime
where
decodeScalar
(
DMT
.
String
x
)
=
case
(
readEither
$
T
.
unpack
x
)
of
Right
r
->
pure
$
NUTCTime
r
Left
err
->
Left
$
T
.
pack
err
decodeScalar
_
=
Left
"Invalid value for NUTCTime"
instance
EncodeScalar
NUTCTime
where
encodeScalar
(
NUTCTime
x
)
=
DMT
.
String
$
T
.
pack
$
show
x
instance
GQLType
NUTCTime
where
type
KIND
NUTCTime
=
SCALAR
instance
FromJSON
NUTCTime
instance
ToJSON
NUTCTime
instance
ToSchema
NUTCTime
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment