Skip to content

Commit 5c02d22

Browse files
nalchevanidze7nalchev
and
7nalchev
authored
Add Morpheus GraphQL to the list of GraphQL libraries (#890)
* ad-mmorpheus-graphql * fix typo * fix code examples * no md escaping * update description Co-authored-by: 7nalchev <[email protected]>
1 parent 8a8d59a commit 5c02d22

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

src/content/code/code.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ In addition to the GraphQL [reference implementations in JavaScript](#javascript
1616
- [Erlang](#erlang)
1717
- [Go](#go)
1818
- [Groovy](#groovy)
19+
- [Haskell](#haskell)
1920
- [Java](#java)
2021
- [JavaScript](#javascript)
2122
- [Julia](#julia)
@@ -170,6 +171,74 @@ See [the documentation](https://grails.github.io/gorm-graphql/latest/guide/index
170171

171172
GQL is a Groovy library for GraphQL
172173

174+
### Haskell
175+
176+
#### [Morpheus GraphQL](https://github.com/morpheusgraphql/morpheus-graphql)
177+
178+
A Haskell library for building GraphQL APIs.
179+
180+
Hello world example with `morpheus-graphql`:
181+
182+
```graphql
183+
# schema.gql
184+
"""
185+
A supernatural being considered divine and sacred
186+
"""
187+
type Deity {
188+
name: String!
189+
power: String @deprecated(reason: "no more supported")
190+
}
191+
192+
type Query {
193+
deity(name: String! = "Morpheus"): Deity!
194+
}
195+
```
196+
197+
198+
```haskell
199+
{-# LANGUAGE DeriveGeneric #-}
200+
{-# LANGUAGE DuplicateRecordFields #-}
201+
{-# LANGUAGE FlexibleContexts #-}
202+
{-# LANGUAGE FlexibleInstances #-}
203+
{-# LANGUAGE MultiParamTypeClasses #-}
204+
{-# LANGUAGE NamedFieldPuns #-}
205+
{-# LANGUAGE OverloadedStrings #-}
206+
{-# LANGUAGE ScopedTypeVariables #-}
207+
{-# LANGUAGE TemplateHaskell #-}
208+
{-# LANGUAGE TypeFamilies #-}
209+
210+
module API (api) where
211+
212+
import Data.ByteString.Lazy.Char8 (ByteString)
213+
import Data.Morpheus (interpreter)
214+
import Data.Morpheus.Document (importGQLDocument)
215+
import Data.Morpheus.Types (RootResolver (..), Undefined (..))
216+
import Data.Text (Text)
217+
218+
importGQLDocument "schema.gql"
219+
220+
rootResolver :: RootResolver IO () Query Undefined Undefined
221+
rootResolver =
222+
RootResolver
223+
{ queryResolver = Query {deity},
224+
mutationResolver = Undefined,
225+
subscriptionResolver = Undefined
226+
}
227+
where
228+
deity DeityArgs {name} =
229+
pure
230+
Deity
231+
{ name = pure name,
232+
power = pure (Just "Shapeshifting")
233+
}
234+
235+
api :: ByteString -> IO ByteString
236+
api = interpreter rootResolver
237+
```
238+
239+
See [morpheus-graphql-examples](https://github.com/morpheusgraphql/morpheus-graphql) for more sophisticated APIs.
240+
241+
173242
### Java
174243

175244
#### [graphql-java](https://github.com/graphql-java/graphql-java)
@@ -598,6 +667,7 @@ Executor.execute(schema, query) map println
598667
- [Elm](#elm)
599668
- [Flutter](#flutter)
600669
- [Go](#go-1)
670+
- [Haskell](#haskell)
601671
- [Java / Android](#java-android)
602672
- [JavaScript](#javascript-1)
603673
- [Julia](#julia)
@@ -634,6 +704,10 @@ Executor.execute(schema, query) map println
634704
- [graphql](https://github.com/shurcooL/graphql#readme): A GraphQL client implementation in Go.
635705
- [machinebox/graphql](https://github.com/machinebox/graphql): An elegant low-level HTTP client for GraphQL.
636706

707+
### Haskell
708+
709+
- [morpheus-graphql-client](https://github.com/morpheusgraphql/morpheus-graphql): A strongly-typed GraphQL client implementation in Haksell.
710+
637711
### Java / Android
638712

639713
- [Apollo Android](https://github.com/apollographql/apollo-android): A strongly-typed, caching GraphQL client for the JVM, Android and Kotlin native.

0 commit comments

Comments
 (0)