morpheus-graphql v0.17.0 Release Notes
-
๐ 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 & @bradsherman
e.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 | Laptops { macAdress :: ID } | Smartphone
this type will generate the following SDL:
enum Unit { Unit } input Laptop { macAdress: ID } input Device { PC: PC Laptops: Laptops 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> }
0๏ธโฃ 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
orimportGQLDocumentWithNamespace
is changed
- ๐ (issue #543 & #558):