morpheus-graphql-0.10.0
Pre-release
Pre-release
Breaking Changes
-
all constructors of
Resolver
:QueryResolver
,MutResolver
,SubResolver
are unexposed. uselift
,publish
orsubscribe
instead.
e.g-- Query Resolver resolveUser :: ResolveQ EVENT IO User resolveUser = lift getDBUser -- Mutation Resolver resolveCreateUser :: ResolveM EVENT IO User resolveCreateUser = do publish [userUpdate] -- publishes event inside mutation lift setDBUser -- Subscription Resolver resolveNewUser :: ResolveS EVENT IO User resolveNewUser = subscribe [USER] $ do pure $ \(Event _ content) -> lift (getDBUserByContent content)
New features
-
exposed
publish
for mutation resolvers, now you can writeresolveCreateUser :: ResolveM EVENT IO User resolveCreateUser = do requireAuthorized publish [userUpdate] liftEither setDBUser
-
exposed
subscribe
for subscription resolvers, now you can writeresolveNewUser :: ResolveS EVENT IO User resolveNewUser = subscribe [USER] $ do requireAuthorized pure userByEvent where userByEvent (Event _ content) = liftEither (getDBUser content)
-
type SubField
will convert your subscription monad to query monad.
SubField (Resolver Subscription Event IO) User
will generate same as
Resolver Subscription Event IO (User ((Resolver QUERY Event IO)))
now if you can define subscription as follows
data Subscription m = Subscription { newUser :: SubField m User }
-
unsafeInternalContext
to get resolver context, use only if it really necessary.
the code depending on it may break even on minor version changes.resolveUser :: ResolveQ EVENT IO User resolveUser = do Context { currentSelection, schema, operation } <- unsafeInternalContext lift (getDBUser currentSelection)