morpheus-graphql v0.2.0 Release Notes
-
โ Added
- ๐ Parser Supports GraphQL comments
- โจ Enhanced Subscription: mutation can trigger subscription with arguments
- ๐ Experimental Support of Input Unions
- GraphQL schema generating with:
Data.Morpheus.Document.toGraphQLDocument
- Generating dummy Morpheus Api from
schema.gql
:
morpheus build schema/mythology.gql src/MythologyApi.hs
๐
convertToJSONName
&convertToHaskellName
has been extended to support all Haskell 2010 reserved identities. detailsGraphQL Client
with Template haskell QuasiQuotes (Experimental, Not fully Implemented)
defineQuery [gql| query GetHero ($byRealm: Realm) { deity (realm:$byRealm) { power fullName } } |]
will Generate:
- response type
GetHero
,Deity
withLens
Instances - input types:
GetHeroArgs
,Realm
- instance for
Fetch
typeClass
so that
fetchHero :: Args GetHero -> m (Either String GetHero) fetchHero = fetch jsonRes args where args = GetHeroArgs {byRealm = Just Realm {owner = "Zeus", surface = Just 10}} jsonRes :: ByteString -> m ByteString jsonRes = <fetch query from server>
resolves well typed response
GetHero
.- Ability to define
GQLSchema
with GraphQL syntax , so that with this schema
[gqlDocument| type Query { deity (uid: Text! ) : Deity! } type Deity { name : Text! power : Text } |] rootResolver :: GQLRootResolver IO () () Query () () rootResolver = GQLRootResolver {queryResolver = return Query {deity}, mutationResolver = pure (), subscriptionResolver = pure ()} where deity DeityArgs {uid} = pure Deity {name, power} where name _ = pure "Morpheus" power _ = pure (Just "Shapeshifting")
Template Haskell Generates types:
Query
,Deity
,DeityArgs
, that can be used byrootResolver
generated types are not compatible with
Mutation
,Subscription
, they can be used only inQuery
, but this issue will be fixed in next release๐ Fixed:
- ๐ Parser supports enums inside input Object
- fulfilled fragment Validation (added: unusedFragment,nameConflict)
- correct decoding of Enums with more than 3 constructor #201
๐ Changed
WebSocket subProtocol changed from
graphql-subscriptions
tographql-ws
๐ type familiy
KIND
is moved into typeClassesGQLType
, so you should replace
type instance KIND Deity = OBJECT instance GQLType Deity where description = const "Custom Description for Client Defined User Type" data Deity = Deity { fullName :: Text } deriving (Generic)
with
instance GQLType Deity where type KIND Deity = OBJECT description = const "Custom Description for Client Defined User Type" data Deity = Deity { fullName :: Text } deriving (Generic)
- Duplicated variable names in Http requests are validated using
Aeson
'sjsonNoDup
function. So the following request will result in a parsing error
{"query":"...", "variables":{"email":"[email protected]", "email":"[email protected]",...}}