Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/morpheusgraphql/morpheus-graphql-cli
Code Generator for Morpheus GraphQL
https://github.com/morpheusgraphql/morpheus-graphql-cli
Last synced: about 2 months ago
JSON representation
Code Generator for Morpheus GraphQL
- Host: GitHub
- URL: https://github.com/morpheusgraphql/morpheus-graphql-cli
- Owner: morpheusgraphql
- License: mit
- Created: 2019-11-01T00:00:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-08T22:50:05.000Z (over 3 years ago)
- Last Synced: 2023-03-02T19:45:43.553Z (almost 2 years ago)
- Language: Haskell
- Homepage:
- Size: 108 KB
- Stars: 13
- Watchers: 3
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# Morpheus GraphQL CLI
Morpheus GraphQL CLI helps you to generate GraphQL APIs .
Morpheus GraphQL CLI is still in an early stage of development, so any feedback is more than welcome, and we appreciate any contribution!
Just open an issue here on GitHub, or join [our Slack channel](https://morpheus-graphql-slack-invite.herokuapp.com/) to get in touch.## Getting Started
### Setup
To get started with Morpheus, you first need to add it to your project's dependencies, as follows (assuming you're using hpack):
_package.yml_
```yaml
dependencies:
- morpheus-graphql-cli
```Additionally, you should tell stack which version to pick:
_stack.yml_
```yaml
resolver: lts-14.8extra-deps:
- morpheus-graphql-0.5.0
```As Morpheus and is quite new, make sure stack can find morpheus-graphql by running `stack upgrade` and `stack update`
## Code Generating
Generating dummy Morpheus Api from `schema.gql`
```
morpheus build src/schem.gql src/GQLApi.hs
```_schema.gql_
```gql
type Query {
deity(name: String!): Deity!
}type Deity {
name: String!
power: String
}
```_API.hs_
```haskell
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeFamilies #-}-- generated by 'Morpheus' CLI
module API (rootResolver) whereimport GHC.Generics (Generic)
import Data.Morpheus.Kind (SCALAR, ENUM, INPUT_OBJECT, OBJECT, UNION)
import Data.Morpheus.Types (GQLRootResolver(..), toMutResolver, IORes, IOMutRes, IOSubRes, Event(..), SubRootRes, GQLType(..), GQLScalar(..), ScalarValue(..))
import Data.Text (Text)rootResolver :: GQLRootResolver IO () () Query () ()
rootResolver =
GQLRootResolver
{ queryResolver = resolveQuery
, mutationResolver = return ()
, subscriptionResolver = return ()
}---- GQL Query -------------------------------
data Query = Query
{ deity :: ArgDeity -> IORes Deity
}
deriving (Generic)data ArgDeity = ArgDeity
{ name :: Text
}
deriving (Generic)instance GQLType Query where
type KIND Query = OBJECTresolveQuery :: IORes Query
resolveQuery = return Query
{ deity = const resolveDeity
}---- GQL Deity -------------------------------
data Deity = Deity
{ name :: () -> IORes Text
, power :: () -> IORes (Maybe Text)
}
deriving (Generic)instance GQLType Deity where
type KIND Deity = OBJECTresolveDeity :: IORes Deity
resolveDeity = return Deity
{ name = const $ return ""
, power = const $ return Nothing
}
```this command will generate Haskell API and resolvers,
resolvers will resolve default values for every object# About
## The name
_Morpheus_ is the greek god of sleep and dreams whose name comes from the greek word _μορφή_ meaning form or shape.
He is said to be able to mimic different forms and GraphQL is good at doing exactly that: Transforming data in the shape
of many different APIs.## Team
Morpheus is written and maintained by [_nalchevanidze_](https://github.com/nalchevanidze)