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
198
Issues
198
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
2999e092
Commit
2999e092
authored
Oct 28, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graphql] implement unprefix for graphql serialization of models
parent
bc8a34b0
Pipeline
#2029
failed with stage
in 10 minutes and 11 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
19 deletions
+41
-19
GraphQL.hs
src/Gargantext/API/GraphQL.hs
+0
-2
Utils.hs
src/Gargantext/API/GraphQL/Utils.hs
+3
-3
Contact.hs
src/Gargantext/Database/Admin/Types/Hyperdata/Contact.hs
+17
-4
User.hs
src/Gargantext/Database/Admin/Types/Hyperdata/User.hs
+11
-4
User.hs
src/Gargantext/Database/Schema/User.hs
+8
-4
stack.yaml
stack.yaml
+2
-2
No files found.
src/Gargantext/API/GraphQL.hs
View file @
2999e092
...
...
@@ -18,8 +18,6 @@ import Data.Maybe (fromMaybe)
import
Data.Morpheus
(
App
,
deriveApp
)
import
Data.Morpheus.App.Internal.Resolving
(
failure
)
import
Data.Morpheus.Server
(
httpPlayground
)
...
...
src/Gargantext/API/GraphQL/Utils.hs
View file @
2999e092
module
Gargantext.API.GraphQL.Utils
where
import
Data.Morpheus.Types
(
GQLTypeOptions
,
fieldLabelModifier
)
import
Data.Morpheus.Types
(
GQLTypeOptions
(
..
)
)
import
qualified
Data.Text
as
T
import
Gargantext.Core.Utils.Prefix
(
unCapitalize
,
dropPrefix
)
import
Gargantext.Prelude
unPrefix
::
T
.
Text
->
GQLTypeOptions
->
GQLTypeOptions
unPrefix
prefix
gqlto
=
fieldLabelModifier
gqlto
nflm
unPrefix
prefix
(
GQLTypeOptions
{
fieldLabelModifier
,
..
})
=
GQLTypeOptions
{
fieldLabelModifier
=
nflm
,
..
}
where
nflm
label
=
unCapitalize
$
dropPrefix
(
T
.
unpack
prefix
)
label
nflm
label
=
unCapitalize
$
dropPrefix
(
T
.
unpack
prefix
)
$
fieldLabelModifier
label
src/Gargantext/Database/Admin/Types/Hyperdata/Contact.hs
View file @
2999e092
...
...
@@ -26,6 +26,7 @@ module Gargantext.Database.Admin.Types.Hyperdata.Contact
import
Data.Morpheus.Types
(
GQLType
(
..
))
import
Data.Time.Segment
(
jour
)
import
qualified
Gargantext.API.GraphQL.Utils
as
GAGU
import
Gargantext.Core.Text
(
HasText
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata.Prelude
import
Gargantext.Prelude
...
...
@@ -42,7 +43,10 @@ data HyperdataContact =
,
_hc_uniqIdBdd
::
Maybe
Text
,
_hc_uniqId
::
Maybe
Text
}
deriving
(
Eq
,
Show
,
Generic
,
GQLType
)
}
deriving
(
Eq
,
Show
,
Generic
)
instance
GQLType
HyperdataContact
where
typeOptions
_
=
GAGU
.
unPrefix
"_hc_"
instance
HasText
HyperdataContact
where
...
...
@@ -89,7 +93,10 @@ data ContactWho =
,
_cw_lastName
::
Maybe
Text
,
_cw_keywords
::
[
Text
]
,
_cw_freetags
::
[
Text
]
}
deriving
(
Eq
,
Show
,
Generic
,
GQLType
)
}
deriving
(
Eq
,
Show
,
Generic
)
instance
GQLType
ContactWho
where
typeOptions
_
=
GAGU
.
unPrefix
"_cw_"
type
FirstName
=
Text
type
LastName
=
Text
...
...
@@ -118,7 +125,10 @@ data ContactWhere =
,
_cw_entry
::
Maybe
NUTCTime
,
_cw_exit
::
Maybe
NUTCTime
}
deriving
(
Eq
,
Show
,
Generic
,
GQLType
)
}
deriving
(
Eq
,
Show
,
Generic
)
instance
GQLType
ContactWhere
where
typeOptions
_
=
GAGU
.
unPrefix
"_cw_"
defaultContactWhere
::
ContactWhere
defaultContactWhere
=
ContactWhere
[
"Organization X"
]
...
...
@@ -135,7 +145,10 @@ data ContactTouch =
ContactTouch
{
_ct_mail
::
Maybe
Text
,
_ct_phone
::
Maybe
Text
,
_ct_url
::
Maybe
Text
}
deriving
(
Eq
,
Show
,
Generic
,
GQLType
)
}
deriving
(
Eq
,
Show
,
Generic
)
instance
GQLType
ContactTouch
where
typeOptions
_
=
GAGU
.
unPrefix
"_ct_"
defaultContactTouch
::
ContactTouch
defaultContactTouch
=
ContactTouch
(
Just
"email@data.com"
)
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/User.hs
View file @
2999e092
...
...
@@ -24,7 +24,7 @@ Portability : POSIX
module
Gargantext.Database.Admin.Types.Hyperdata.User
where
import
Data.Morpheus.Types
(
GQLType
(
typeOptions
)
,
defaultTypeOptions
)
import
Data.Morpheus.Types
(
GQLType
(
typeOptions
))
import
qualified
Gargantext.API.GraphQL.Utils
as
GAGU
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata.Prelude
...
...
@@ -41,19 +41,26 @@ data HyperdataUser =
}
deriving
(
Eq
,
Show
,
Generic
)
instance
GQLType
HyperdataUser
where
typeOptions
_
=
GAGU
.
unPrefix
"_hu_"
defaultTypeOptions
typeOptions
_
=
GAGU
.
unPrefix
"_hu_"
data
HyperdataPrivate
=
HyperdataPrivate
{
_hpr_password
::
!
Text
,
_hpr_lang
::
!
Lang
}
deriving
(
Eq
,
Show
,
Generic
,
GQLType
)
deriving
(
Eq
,
Show
,
Generic
)
instance
GQLType
HyperdataPrivate
where
typeOptions
_
=
GAGU
.
unPrefix
"_hpr_"
data
HyperdataPublic
=
HyperdataPublic
{
_hpu_pseudo
::
!
Text
,
_hpu_publications
::
!
[
DocumentId
]
}
deriving
(
Eq
,
Show
,
Generic
,
GQLType
)
deriving
(
Eq
,
Show
,
Generic
)
instance
GQLType
HyperdataPublic
where
typeOptions
_
=
GAGU
.
unPrefix
"_hpu_"
-- | Default
defaultHyperdataUser
::
HyperdataUser
...
...
src/Gargantext/Database/Schema/User.hs
View file @
2999e092
...
...
@@ -20,15 +20,16 @@ Functions to deal with users, database side.
module
Gargantext.Database.Schema.User
where
import
Data.Morpheus.Types
(
GQLType
)
import
Data.Morpheus.Types
(
GQLType
(
typeOptions
)
)
import
Data.Text
(
Text
)
import
Data.Time
(
UTCTime
)
import
qualified
Gargantext.API.GraphQL.Utils
as
GAGU
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
import
Gargantext.Database.Prelude
(
fromField'
)
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
import
Database.PostgreSQL.Simple.FromField
(
FromField
,
fromField
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Gargantext.Database.Prelude
(
fromField'
)
import
Gargantext.Core.Utils.Prefix
(
unPrefix
)
-- FIXME PLZ : the import below leads to an error, why ?
-- import Gargantext.Database.Schema.Prelude hiding (makeLensesWith, abbreviatedFields, makeAdaptorAndInstance)
...
...
@@ -43,7 +44,10 @@ data UserLight = UserLight { userLight_id :: !Int
,
userLight_username
::
!
Text
,
userLight_email
::
!
Text
,
userLight_password
::
!
Text
}
deriving
(
Show
,
Generic
,
GQLType
)
}
deriving
(
Show
,
Generic
)
instance
GQLType
UserLight
where
typeOptions
_
=
GAGU
.
unPrefix
"userLight_"
toUserLight
::
UserDB
->
UserLight
toUserLight
(
UserDB
id
p
_
_
u
_
_
e
_
_
_
)
=
UserLight
id
u
e
p
...
...
stack.yaml
View file @
2999e092
...
...
@@ -86,8 +86,8 @@ extra-deps:
commit
:
83ada76e78ac10d9559af8ed6bd4064ec81308e4
-
accelerate-arithmetic-1.0.0.1@sha256:555639232aa5cad411e89247b27871d09352b987a754230a288c690b6de6d888,2096
-
git
:
https://github.com/
morpheusgraphql
/morpheus-graphql.git
commit
:
339ee745049febbf2e7fd6fabf1e01afab19d0a
9
-
git
:
https://github.com/
CGenie
/morpheus-graphql.git
commit
:
899b7bf21274739beae84b27812f76e2a5e67e2
9
subdirs
:
-
.
-
morpheus-graphql-app
...
...
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