Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
nalchevanidze committed Nov 1, 2019
1 parent 272fdd5 commit a8dbc58
Show file tree
Hide file tree
Showing 20 changed files with 1,123 additions and 1 deletion.
122 changes: 122 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
version: 2.1
jobs:
## Lowest GHC Version
ghc_8_2_2:
docker:
- image: fpco/stack-build:lts-11.10
steps:
- checkout
- restore_cache:
name: restore cached stack
keys:
- stack-vesrion-{{ checksum "stack-11.10.yaml" }}
- restore_cache:
name: restore cached dependencies
keys:
- stack-dependencies-{{ checksum "stack-11.10.yaml" }}-{{ checksum "package.yaml" }}
- run:
name: setup stack
command: STACK_YAML=stack-11.10.yaml stack --no-terminal setup
- save_cache:
name: cache stack
key: stack-vesrion-{{ checksum "stack-11.10.yaml" }}
paths:
- /root/.stack
- run:
name: install dependencies
command: STACK_YAML=stack-11.10.yaml stack build --skip-ghc-check --no-terminal --test --only-dependencies
- save_cache:
name: cache dependencies
key: stack-dependencies-{{ checksum "stack-11.10.yaml" }}-{{ checksum "package.yaml" }}
paths:
- ".stack-work"
- "/root/.stack"
- run:
name: run tests
command: STACK_YAML=stack-11.10.yaml stack test --haddock --no-haddock-deps
- run:
name: Install executables
command: STACK_YAML=stack-11.10.yaml stack install

ghc_8_4_4:
docker:
- image: fpco/stack-build:lts-12.16
steps:
- checkout
- restore_cache:
name: restore cached stack
keys:
- stack-vesrion-{{ checksum "stack-12.16.yaml" }}
- restore_cache:
name: restore cached dependencies
keys:
- stack-dependencies-{{ checksum "stack-12.16.yaml" }}-{{ checksum "package.yaml" }}
- run:
name: setup stack
command: STACK_YAML=stack-12.16.yaml stack --no-terminal setup
- save_cache:
name: cache stack
key: stack-vesrion-{{ checksum "stack-12.16.yaml" }}
paths:
- /root/.stack
- run:
name: install dependencies
command: STACK_YAML=stack-12.16.yaml stack build --skip-ghc-check --no-terminal --test --only-dependencies
- save_cache:
name: cache dependencies
key: stack-dependencies-{{ checksum "stack-12.16.yaml" }}-{{ checksum "package.yaml" }}
paths:
- ".stack-work"
- "/root/.stack"
- run:
name: Run tests
command: STACK_YAML=stack-12.16.yaml stack test --haddock --no-haddock-deps
- run:
name: Install executables
command: STACK_YAML=stack-12.16.yaml stack install

## GHC 8.6.5
ghc_8_6_5:
docker:
- image: fpco/stack-build:lts
steps:
- checkout
- restore_cache:
name: restore cached stack
keys:
- stack-vesrion-{{ checksum "stack.yaml" }}
- restore_cache:
name: restore cached dependencies
keys:
- stack-dependencies-{{ checksum "stack.yaml" }}-{{ checksum "package.yaml" }}
- run:
name: setup stack
command: stack --no-terminal setup
- save_cache:
name: cache stack
key: stack-vesrion-{{ checksum "stack.yaml" }}
paths:
- /root/.stack
- run:
name: install dependencies
command: stack build --skip-ghc-check --no-terminal --test --only-dependencies
- save_cache:
name: cache dependencies
key: stack-dependencies-{{ checksum "stack.yaml" }}-{{ checksum "package.yaml" }}
paths:
- ".stack-work"
- "/root/.stack"
- run:
name: Run tests
command: stack test --haddock --no-haddock-deps
- run:
name: Install executables
command: stack install

workflows:
version: 2.1
build_all:
jobs:
- ghc_8_2_2
- ghc_8_4_4
- ghc_8_6_5
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.stack-work/
.idea/
morpheus-graphql-cli.cabal
morpheus-graphql-cli.iml
docs/vendor
out/
7 changes: 7 additions & 0 deletions HLint.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module HLint.HLint where

import "hint" HLint.Default
import "hint" HLint.Builtin.All
import "hint" HLint.Dollar

ignore "Use camelCase"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Daviti Nalchevanidze

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
138 changes: 137 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,137 @@
# morpheus-graphql-cli
# 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
```
Additionally, you should tell stack which version to pick:
_stack.yml_
```yaml
resolver: lts-14.8

extra-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) where

import 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 = OBJECT



resolveQuery :: 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 = OBJECT



resolveDeity :: 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)
2 changes: 2 additions & 0 deletions Setup.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
Empty file added changelog.md
Empty file.
Loading

0 comments on commit a8dbc58

Please sign in to comment.