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
    

    details

    • ๐Ÿ‘ 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:

    • response type GetHero, Deity with Lens 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 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

    ๐Ÿ›  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 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)
    
    • 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]",...}}