From 1279e132e693a6a88e2affa4aa5b1b72f97f8920 Mon Sep 17 00:00:00 2001 From: nalchevanidze Date: Wed, 9 Oct 2019 01:37:23 +0200 Subject: [PATCH] Release 0.4.0 (#263) * update version in changelog * update version in package.yml * get Types * update readme * update client readme * updateFather Of * update changelog date --- README.md | 68 ++++++++++++++++++++++++++++++++++++++------------ changelog.md | 2 +- docs/index.md | 69 +++++++++++++++++++++++++++++++++++++++------------ package.yaml | 2 +- 4 files changed, 107 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 5c8e69a73f..fe630c309b 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ _stack.yml_ resolver: lts-13.30 extra-deps: - - morpheus-graphql-0.3.1 + - morpheus-graphql-0.4.0 - aeson-1.4.4.0 - time-compat-1.9.2.2 ``` @@ -351,49 +351,85 @@ rootResolver = ## Morpheus `GraphQL Client` with Template haskell QuasiQuotes -```haskell +```hs defineByDocumentFile "./schema.gql" [gql| - query GetHero ($byRealm: Realm) + query GetHero ($character: Character) { - deity (realm:$byRealm) { + deity (fatherOf:$character) { + name power - fullName + worships { + deity2Name: name + } } } |] ``` +with schema: + +```gql +input Character { + name: String! +} + +type Deity { + name: String! + worships: Deity +} +``` + will validate query and Generate: -- response type `GetHero`, `Deity` with `Lens` Instances -- input types: `GetHeroArgs` , `Realm` +- namespaced response and variable types - instance for `Fetch` typeClass -so that +```hs +data GetHero = GetHero { + deity: DeityDeity +} + +-- from: {user +data DeityDeity = DeityDeity { + name: Text, + worships: Maybe DeityWorshipsDeity +} + +-- from: {deity{worships +data DeityWorshipsDeity = DeityWorshipsDeity { + name: Text, +} + +data GetHeroArgs = GetHeroArgs { + getHeroArgsCharacter: Character +} + +data Character = Character { + characterName: Person +} +``` + +as you see, response type field name collision can be handled with GraphQL `alias`. + +with `fetch` you can fetch well typed response `GetHero`. ```haskell fetchHero :: Args GetHero -> m (Either String GetHero) fetchHero = fetch jsonRes args where - args = GetHeroArgs {byRealm = Just Realm {owner = "Zeus", surface = Just 10}} + args = GetHeroArgs {getHeroArgsCharacter = Person {characterName = "Zeus"}} jsonRes :: ByteString -> m ByteString jsonRes = ``` -resolves well typed response `GetHero`. - -except: `defineByDocumentFile` you can use: +types can be generatet from `introspection` too: ```haskell defineByIntrospectionFile "./introspection.json" ``` -or - -`defineByIntrospection` where you can directly connect it to server - ## Morpheus CLI for Code Generating Generating dummy Morpheus Api from `schema.gql` diff --git a/changelog.md b/changelog.md index 714d0be695..583503c8d5 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,4 @@ -## [0.3.2] - \*.2019 +## [0.4.0] - 09.10.2019 ## Changed diff --git a/docs/index.md b/docs/index.md index 70370da066..52cfe3ecfb 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,6 +1,7 @@ --- layout: home --- + # Morpheus GraphQL [![Hackage](https://img.shields.io/hackage/v/morpheus-graphql.svg)](https://hackage.haskell.org/package/morpheus-graphql) [![CircleCI](https://circleci.com/gh/morpheusgraphql/morpheus-graphql.svg?style=svg)](https://circleci.com/gh/morpheusgraphql/morpheus-graphql) Build GraphQL APIs with your favourite functional language! @@ -32,7 +33,7 @@ _stack.yml_ resolver: lts-13.30 extra-deps: - - morpheus-graphql-0.3.1 + - morpheus-graphql-0.4.0 - aeson-1.4.4.0 - time-compat-1.9.2.2 ``` @@ -354,49 +355,85 @@ rootResolver = ## Morpheus `GraphQL Client` with Template haskell QuasiQuotes -```haskell +```hs defineByDocumentFile "./schema.gql" [gql| - query GetHero ($byRealm: Realm) + query GetHero ($character: Character) { - deity (realm:$byRealm) { + deity (fatherOf:$character) { + name power - fullName + worships { + deity2Name: name + } } } |] ``` +with schema: + +```gql +input Character { + name: String! +} + +type Deity { + name: String! + worships: Deity +} +``` + will validate query and Generate: -- response type `GetHero`, `Deity` with `Lens` Instances -- input types: `GetHeroArgs` , `Realm` +- namespaced response and variable types - instance for `Fetch` typeClass -so that +```hs +data GetHero = GetHero { + deity: DeityDeity +} + +-- from: {user +data DeityDeity = DeityDeity { + name: Text, + worships: Maybe DeityWorshipsDeity +} + +-- from: {deity{worships +data DeityWorshipsDeity = DeityWorshipsDeity { + name: Text, +} + +data GetHeroArgs = GetHeroArgs { + getHeroArgsCharacter: Character +} + +data Character = Character { + characterName: Person +} +``` + +as you see, response type field name collision can be handled with GraphQL `alias`. + +with `fetch` you can fetch well typed response `GetHero`. ```haskell fetchHero :: Args GetHero -> m (Either String GetHero) fetchHero = fetch jsonRes args where - args = GetHeroArgs {byRealm = Just Realm {owner = "Zeus", surface = Just 10}} + args = GetHeroArgs {getHeroArgsCharacter = Person {characterName = "Zeus"}} jsonRes :: ByteString -> m ByteString jsonRes = ``` -resolves well typed response `GetHero`. - -except: `defineByDocumentFile` you can use: +types can be generatet from `introspection` too: ```haskell defineByIntrospectionFile "./introspection.json" ``` -or - -`defineByIntrospection` where you can directly connect it to server - ## Morpheus CLI for Code Generating Generating dummy Morpheus Api from `schema.gql` diff --git a/package.yaml b/package.yaml index 38f2f1599e..c4171d7d82 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: morpheus-graphql -version: 0.3.1 +version: 0.4.0 github: "nalchevanidze/morpheus-graphql" license: BSD3 author: "Daviti Nalchevanidze"