morpheus-graphql-0.17.0
Server
new features
-
(issue #543 & #558):
GQLTypeOptions
supports new optiontypeNameModifier
.
Before the schema failed if you wanted to use the same type for input and output, and the user had no control over the eventual GraphQL type name of the generated schema. Now with this option you can
provide a function of typeBool -> String -> String
that generates a custom GraphQL type name. The first argument is aBool
that isTrue
if the type is an input, andFalse
otherwise. The second
argument is aString
representing the initial, auto-generated GraphQL type name. The function returns the desired type name. thanks @nalchevanidze & @bradshermane.g this schema will not fail. morpheus will generate types:
Deity
andInputDeity
data Deity = Deity { name :: Text, age :: Int } deriving (Show, Generic) deityTypeNameModifier isInput original | isInput = "Input" ++ original | otherwise = original instance GQLType Deity where typeOptions _ opt = opt {typeNameModifier = deityTypeNameModifier} newtype DeityArgs = DeityArgs { input :: Deity } deriving (Show, Generic, GQLType) newtype Query (m :: * -> *) = Query { deity :: DeityArgs -> m Deity } deriving (Generic, GQLType)
-
exposed
EncodeWrapper
andDecodeWrapper
type-classes.
Breaking Changes
-
Map k v
is now represented as just[Pair k v]
-
GQLScalar
was replaced withEncodeScalar
andDecodeScalar
type-classes. -
Exclusive input objects: Sum types used as input types are represented as input objects, where only one field must have a value. Namespaced constructors (i.e., where referenced type name concatenated with union type name is equal to constructor name) are unpacked. Furthermore, empty constructors are represented as fields with the unit type.
for example:
data Device | DevicePC PC | Laptop { macAdress :: ID } | Smartphone
this type will generate the following SDL:
enum Unit { Unit } input Laptop { macAdress: ID } input Device { PC: PC Laptops: Laptop Smartphone: Unit }
-
For each nullary constructor will be defined GQL object type with a single field
_: Unit
(since GraphQL does not allow empty objects).for example:
data Person = Client { name :: Text } | Accountant | Developer
this type will generate the following SDL:
enum Unit { Unit } type Student { name: String! } type Accountant { _: Unit! } type Developer { _: Unit! } union Person = Client | Accountant | Developer
-
changed signature of
GQLType.typeOptions
fromf a -> GQLTypeOptions
tof a -> GQLTypeOptions -> GQLTypeOptions
.now you can write:
typeOptions _ options = options { fieldLabelModifier = <my function> }
whre argument options is default gql options.
-
deexposed constructor of
GQLTypeOptions
. -
Type name for parametrized types like
One (Two Three)
will be generated directly, concatenating themOneTwoThree
instead ofOne_Two_Three.
-
Haskell
Float
was renamed to custom scalar typeFloat32.
-
Haskell
Double
now represents GraphQLFloat
.
Minor Changes
- deprecated kinds
INPUT
,ENUM
andOUTPUT
in favor of more generalized kindTYPE
.
now you can derive INPUT, ENUM and OUTPUT automatically withderiving (Generic, GQLType)
. - more likely to rebuild when a file loaded by
importGQLDocument
or
importGQLDocumentWithNamespace
is changed
Client
Breaking changes
GQLScalar
was replaced withEncodeScalar
andDecodeScalar
type-classes.
Minor Changes
- more likely to rebuild when a file loaded by
defineByDocumentFile
or
defineByIntrospectionFile
is changed
Core
New features
Data.Morpheus.Core
provides default GrapHQL type definitions withinternalSchema
- exposed
Data.Morpheus.Internal.Ext
Breaking changes
-
parseTypeSystemDefinition
andparseGQLDocument
is replaced withparseSchema
-
parseFullGQLDocument
replaced withparseFullSchema
-
removed
parseDSL
fromData.Morpheus.Core
-
following Types and modules are migrated to the new package
morpheus-graphql-app
:- following types and functions in
Data.Morpheus.Core
are moved in toData.Morpheus.App
:
App
,AppData
,runApp
,withDebugger
,mkApp
,runAppStream
- typeClass
MapAPI
migrated fromData.Morpheus.Types.IO
is moved intoData.Morpheus.App
Data.Morpheus.Types.Internal.Resolving
moved asData.Morpheus.App.Internal.Resolving
- following types and functions in
-
RootResModel
was renamed toRootResolverValue
-
ResModel
was replaced with more generalResolverValue
-
GQLScalar
was replaced withEncodeScalar
andDecodeScalar
type-classes. -
Value.Float
is nowDouble
instead ofFloat
.