Bot releases are visible (Hide)
Published by nalchevanidze about 5 years ago
attoparsec
, utf8-string
1.4.4.0
Published by nalchevanidze about 5 years ago
user can import GraphQL Document and generate types with it.
importGQLDocument "API.gql"
this will generate types defined in API.gql
String
defined in GQLDcoument will be converted to Text
by template haskell
importGQLDocument
and gqlDocument
supports Mutation, Subscription and Resolvers with custom Monad
for example. if we have:
type Deity {
name: String!
power: Power!
}
where Power
is another object defined by gql schema.
template haskell will represent this type as:
data Deity m = Deity {
name :: () -> m Text,
power :: () -> m (Power m)
}
where m
is resolver Monad.
importGQLDocumentWithNamespace
generates namespaced haskell records. so that you have no more problem with name collision.
from this gql type:
type Deity {
name: (id:Int)String!
power: Power!
}
will be generated.
data Deity m = Deity {
deityName :: DeityNameArgs -> m Text,
deityPower :: () -> m (Power m)
}
data DeityNameArgs = DeityNameArgs {
deityNameArgsId :: Int
}
GQLType
is mandatory for every GQL Type (including Query, Mutation and Subscription)
subscription Resolver changed
from:
Subscription {newDeity = \args -> Event {channels = [ChannelA], content = newDeityResolver } }
to:
Subscription {newDeity = \args -> SubResolver {subChannels = [ChannelA], subResolver = newDeityResolver } }
Published by nalchevanidze about 5 years ago
Parser Supports GraphQL multiline comments
Morpheus GraphQL Client: Support GraphQL Alias
Support of GraphQL Interfaces on GraphQL Document:
# simple.gql
interface Node {
nodeId: ID!
}
type SimpleType implements Node {
nodeId: ID!
name: Text!
}
morpheus compiler will read interfaces and validate implements.
template haskell will generate haskell types only for types not for interfaces.
haskell type from simple.gql
:
data SimpleType = SimpleType {
nodeId :: ID!
name :: Text!
} deriving (Generic)
at the time compiler does not validates field Arguments by interface
Published by nalchevanidze about 5 years ago
Published by nalchevanidze about 5 years ago
thank you for contributing: @horus @ryota-ka @hovind @gvolpe
Parser Supports GraphQL Single Line 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. details
GraphQL Client
with Template haskell QuasiQuotes (Experimental, Not fully Implemented)
defineQuery
[gql|
query GetHero ($byRealm: Realm)
{
deity (realm:$byRealm) {
power
fullName
}
}
|]
will Generate:
GetHero
, Deity
with Lens
InstancesGetHeroArgs
, Realm
Fetch
typeClassso 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 by rootResolver
generated types are not compatible with Mutation
, Subscription
,
they can be used only in Query
, but this issue will be fixed in next release
Parser supports enums inside input Object
fulfilled fragment Validation (added: unusedFragment,nameConflict)
correct decoding of Enums with more than 3 constructor #201
Duplicated variable names in Http requests are validated using Aeson
's jsonNoDup
function. So the following request will
result in a parsing error
{"query":"...",
"variables":{"email":"[email protected]", "email":"[email protected]",...}}
WebSocket subProtocol changed from graphql-subscriptions
to graphql-ws
type familiy KIND
is moved into typeClasses GQLType
, 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)
Published by nalchevanidze over 5 years ago
Fixed:
Published by nalchevanidze over 5 years ago
thanks for contributing to: @krisajenkins, @hovind, @vmchale, @msvbg
type instance KIND <type> = UNION
Map
, Set
, and Pair (a,b)
Interpreter
class with instances:
ByteString -> m ByteString
and Lazy ByteString
, where m
is resolver monadText -> m Text
and Lazy Text
, where m
is resolver monadGQLRequest -> m GQLResponse
, When you using it inside another Component that have Manual ToJSON
deriving,GQLResponse
will be encoded with toEncoding
, and not with toJSON
.Objects
,Arrays
ID
GQLScalar
instance function parseValue
KIND
with:
SCALAR
OBJECT
,ENUM
INPUT_OBJECT
UNION
GQLSubscription
a -> EffectM b
operation: is resolver that contains side effect in EffectM
.gqlEffectResolver ["CHANNEL_ID"]
: packs as effect Resolver.GQLState
: shared state between http
and websocket
servergqlSocketApp
:converts interpreter
to websocket
applicationgraphql-subscriptions
: Apollo GraphQL
subProtocol__type(name:"type")
__typename
GQLRootResolver
, GQLType(..)
, GQLScalar(..)
Data.Morpheus.Types
GQLRoot { query, mutation, subscription }
to GQLRootResolver {queryResolver, mutationResolver, subscriptionResolver}
interpreter
: can be used in http
and websocket
serverGQLKind
renamed as GQLType
(Generic,GQLType)
type'
will generate GQL Object field type
Non-Null
and List
GQLArgs
: you can derive arguments just with Generic
without GQLArgs
GQLObject
: replaced with instance type instance KIND <Type> = OBJECT
GQLEnum
: replaced with instance type instance KIND <Type> = ENUM
GQLInput
: replaced with instance type instance KIND <Type> = INPUT_OBJECT
Typeable
: with new deriving it is not required anymoreWrapper
: with TypeFamilies there is no need for Wrapper
a ::-> b
is Replaced by a -> ResM b
where ResM
is alias for Resolver IO a
GQLMutation
, GQLQuery
: with new deriving it is not required anymoreResolver
constructor replaced by functions:
gqlResolver
: packs m Either String a
to Resolver m a
gqlEffectResolver
: resolver constructor for effectedResolverliftEffectResolver
: lifts normal resolver to Effect Resolver.Published by nalchevanidze over 5 years ago