Releases: morpheusgraphql/morpheus-graphql
0.19.1
0.19.1 (2022-03-31)
New features
- #694: Export a function to add extensions to errors
Bug Fixes
- #695: fix(client): avoid generating duplicated Aeson instances
-
📦 client
-
👤 @lorenzo
-
When generating the code for different queries that share the same schema, morphreus tries to emit Aeson instances multiple times, which does not work.
With this change, before generating a the instance, it will lookup
if it was declared already and avoid doing so.This also helps when you want to take over and declare some things
manualy and let morpheus do the rest.Additionally, this add a
omitNulls
pass to the generated Aeson object.
When sending the object for a type with lots of nullables, this reduces
significantly the request size.
-
Minor Changes
- #693: feat(deployment): automatic package check
- #698: Init automatic deployment workflow
- 👤 @nalchevanidze
-
Automatic creation of a change log and package update based on the pull request since the last tag.
- #699: Setup workflow to create the release
morpheus-graphql-0.19.0
morpheus-graphql-0.18.0
new Features
server
-
NamedResoplvers
(experimental featuure): typed Haskell approach of providing appollo
like named resolvers, apps with NamedResolvers theoretically can be safelly merged. -
TypeGuards
: as an alternative for interfaces -
TaggedArguments
: support of type level tagged argument definition. for example:Haskell field definition
myField :: Arg "a" Int -> Arg "b" (Maybe Text) -> m Text
will generate GraphQL field
myField(a:Int!, b:String): String!
-
deriving will merge function arguments. for example:
for following data type definitions:
data A = A { a1 :: Text, a2 :: Int} deriving (Show, Generic, GQLType) data B = B {b :: Text} deriving (Show, Generic, GQLType)
Haskell field definition
myField :: A -> B -> m Text
will generate GraphQL field
myField(a1:String!, a2:Int!, b:String!): String!
Breaking Changes
server
- non object variants constructors will be also unpacked
- removed
implements
field fromGQLType
- removed
interface
fromMorpheus.Types
- deprecated kind
INTERFACE
Minor Changes
core
- GraphQL errors support additional field
extensions :: Maybe Value
- the parser reports invalid empty selection sets
- The parser is compliant with the GQL specification and supports all valid characters #581
- The parser performance improvement: on average 3-4 times faster, in some cases more than 100 times faster.
client
-
Add defineBy*File' variants that take a
Q FilePath
#584 -
fixed: Generation of data constructors for non-capitalized enums
-
fixed invalid scalar type generation and added tests to ensure their validity for each upcoming version #583
-
return all response errors gracefully as a Left when fetching #577 - Thanks @AlistairB
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
.
morpheus-graphql-0.16.0
morpheus-graphql
Breaking changes
- subscriptions are extracted in
morpheus-graphql-subscriptions
. Event
,httpPubApp
andwebSocketsApp
movedData.Morpheus.Subscriptions
New Features
-
Data.Morpheus.Subscriptions
provides:- runPubApp: generalized version of
httpPubApp
- runSubApp: generalized version of
webSocketsApp
- runPubApp: generalized version of
-
New encode and decode instances for
Set
,NonEmpty
,Seq
andVector
Set
andNonEmpty
throw a graphql error when a duplicate is found (Set)
or when an empty list is sent (NonEmpty).
Beware: Right now, all these types are advertised as lists in the introspection query.
This is something we are trying to change by submitting a proposal to the graphql spec.
morpheus-graphql-core
Breaking Changes
-
signature changes:
-
render
:
a -> Text
toa -> ByteString
-
parseTypeSystemDefinition :
Text -> Eventless (Schema VALID)
toByteString -> Eventless (Schema VALID)
-
parseTypeDefinitions:
Text -> Eventless [TypeDefinition ANY CONST]
toByteString -> Eventless [TypeDefinition ANY CONST]
-
Minor Changes
- parser performance optimization
morpheus-graphql-client
Minor Changes
morpheus-graphql-0.15.1
relaxed upper boundary of megaparsec
up to 10.0.0
morpheus-graphql-0.15.0
morpheus-graphql
new features
- custom operation root types: e.g
RootResolver IO () MyQuery MyMutation Undefined
- type :
App event m
andderiveApp
App
supports semigroup(schema Stitching
): if whe have two graphql appsGQLType
exposestypeOptions
to modify labels:typeOptions :: f a -> GQLTypeOptions
- you can use
GQLType.getDescriptions
to document field or enum Values
breaking Changes
importGQLDocumentWithNamespace
they will be namespaced enum Values- Argument types must have
GQLType
instances - in
Data.Morpheus.Server
:- removed
subscriptionApp
- changed
webSocketsApp
type toApp e m -> m (ServerApp, e -> m ())
- changed
httpPubApp
type to[e -> m ()] -> App e m -> a -> m b
- removed
- removed
Stream
fromData.Morpheus.Types
- removed class
Interpreter
,interpreter
is now just regular function.
morpheus-graphql-core
new features
render
renders SchemaDefinition e.g- query validator automatically adds
__typename
to interface types - type :
App
App
supports semigroup(schema Stitching
):runApp
changed signature to:
breaking Changes
- removed
runApi
.
morpheus-graphql-client
morpheus-graphql-0.14.1
- fixed Build error during testing #5602
morpheus-graphql-0.14.0
morpheus-graphql
new features
- query validation supports interfaces
debugInterpreter
: displays internal context on grahql errors- compileTimeSchemaValidation :
morpheus validates schema at runtime (after the schema derivation).
to be ensure that only correct api is compiled.
we can use template haskell methodcompileTimeSchemaValidation
import Morpheus.Graphql.Server(compileTimeSchemaValidation)
_validateSchema :: ()
_validateSchema = $(compileTimeSchemaValidation (Identity gqlRoot))
-
directive Validation for Document (TypeSystem).
-
supports of block string values. e.g:
query { createDeity( name: """ powerqwe bla \n sd blu \\ dete """ ) { name } }
-
Data.Morpheus.Document
exposesRootResolverConstraint
-
Data.Morpheus.Server
exposeshttpPlayground
-
httpPubApp
supportsGQLRequest -> GQLResponse
-
morpheus-graphql-core
support ofschema
. issue #412schema { query: Query }
note that this does not affect
morpheus-graphql-server
at all. since it has its own schema derivation. you still need to provide:rootResolver :: RootResolver () IO Query Undefined Undefined rootResolver = RootResolver <resolvers ...>
-
Subscription Resolver supports
Monad
. -
nested Subscription Resolvers.
Breaking Changes
Context' renamed to
ResolverContext'- internal refactoring: changed AST
- root subscribtion fields must be wrapped with
SubscriptionField
. e.g:
data Subscription (m :: * -> *) = Subscription
{ newDeity :: SubscriptionField (m Deity),
newHuman :: HumanArgs -> SubscriptionField (m Human)
}
deriving (Generic)
- signature of
subscribe
is changed. now you can use it as followed:
resolveNewAdress :: SubscriptionField (ResolverS EVENT IO Address)
resolveNewAdress = subscribe ADDRESS $ do
-- executed only once
-- immediate response on failures
requireAuthorized
pure $ \(Event _ content) -> do
-- exectues on every event
lift (getDBAddress content)
- removed from
Data.Morpheus.Types
SubField
ComposedSubField
morpheus-graphql-client
new features
-
supports interfaces.
-
supports of block string values.
-
support of
schema
. issue #412schema { query: MyQuery }
-
generated types have instance of class
Eq
breaking changes
- custom scalars Should Provide instance of class
Eq
0.13.0 - 22.06.2020
morpheus-graphql-core
new features
-
query validation supports interfaces
-
exposed:
Data.Morpheus.Types.SelectionTree
-
configurable api:
Data.Morpheus.Core
exportsConfig
defaultConfig
debugConfig
-
for better debuging, internal errors messages will display resolving state:
current TypeName
current Selection
OperationDefinition
SchemaDefinition
-
rendering graphql "AST". e.g
render ( slection :: Selection VALID)
will render
{
user(arg1: 1) {
name
}
}
- quasiqouter
[dsl| <type definitions> |]
generatesSchema VALID
. - parser supports custom directive definition. e.g
directive @MyDirective on FIELD_DEFINITION | OBJECT
-
directive Validation for Document (TypeSystem).
-
supports of block string values. e.g:
query { createDeity( name: """ powerqwe bla \n sd blu \\ dete """ ) { name } }
-
support of
schema
. issue #412schema { query: MyQuery }
Breaking Changes
Context' renamed to
ResolverContext'- removed :
EventCon
fromData.Morpheus.Core
- internal refactoring: changed AST.
Schema AST Types now need parameterstage = RAW | CONST | VALID
.Schema VALID
TypeDefinition VALID
FieldDefinition IN VALID
- ...
- runApi requires argument config
runApi :: Schema s -> RootResModel event m -> Config -> GQLRequest -> ResponseStream event m (Value VALID)
morpheus-graphql-0.13.0
0.13.0 - 22.06.2020
morpheus-graphql
breaking changes
- renamed
GQLRootResolver
->RootResolver
new features
importGQLDocument
automatically definesGQLType
instances for scalar definitions- supports default values
morpheus-graphql-core
new features
- exposed:
Data.Morpheus.Types.GQLScalar
- exposed:
Data.Morpheus.Types.ID
- finished interface validation
- supports default values
minor changes
- internal refactoring
- added dependency
mtl
- validates strings as enum from JSON value
morpheus-graphql-client
breaking changes
-
from now you should provide for every custom graphql scalar definition coresponoding haskell type definition and
GQLScalar
implementation fot it. for details seeexamples-client
-
input fields and query arguments are imported without namespacing