Skip to content

Repository files navigation

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 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

dependencies:
- morpheus-graphql-cli

Additionally, you should tell stack which version to pick:

stack.yml

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

typeQuery {
deity(name: String!): Deity!
}
typeDeity {
name: String!power: String
}

API.hs

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE TypeFamilies #-}
-- generated by 'Morpheus' CLImoduleAPI (rootResolver) whereimportGHC.Generics (Generic)
importData.Morpheus.Kind (SCALAR, ENUM, INPUT_OBJECT, OBJECT, UNION)
importData.Morpheus.Types (GQLRootResolver(..), toMutResolver, IORes, IOMutRes, IOSubRes, Event(..), SubRootRes, GQLType(..), GQLScalar(..), ScalarValue(..))
importData.Text (Text)
rootResolver::GQLRootResolverIO()()Query()()
rootResolver =GQLRootResolver
{ queryResolver = resolveQuery
, mutationResolver =return()
, subscriptionResolver =return()
}
---- GQL Query -------------------------------dataQuery=Query{deity::ArgDeity->IOResDeity}deriving (Generic)
dataArgDeity=ArgDeity{name::Text}deriving (Generic)
instanceGQLTypeQuerywheretypeKINDQuery=OBJECTresolveQuery::IOResQuery
resolveQuery =returnQuery
{ deity =const resolveDeity
}
---- GQL Deity -------------------------------dataDeity=Deity{name::()->IOResText
, power::()->IORes (MaybeText)
}deriving (Generic)
instanceGQLTypeDeitywheretypeKINDDeity=OBJECTresolveDeity::IOResDeity
resolveDeity =returnDeity
{ name =const$return""
, power =const$returnNothing
}

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

About

Code Generator for Morpheus GraphQL

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages