MyNixOS website logo
Description

Morpheus GraphQL CLI.

code generator for Morpheus GraphQL

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

type Query {
  deity(name: String!): Deity!
}

type Deity {
  name: String!
  power: String
}

API.hs

{-# 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.

Metadata

Version

0.1.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows