morpheus-graphql-code-gen: Morpheus GraphQL CLI

[ bsd3, cli, graphql, library, program, web ] [ Propose Tags ]

code generator for Morpheus GraphQL


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.18.0, 0.19.0, 0.19.1, 0.19.2, 0.19.3, 0.20.0, 0.20.1, 0.21.0, 0.22.0, 0.22.1, 0.23.0, 0.24.0, 0.24.1, 0.24.2, 0.24.3, 0.25.0, 0.26.0, 0.27.0, 0.27.1, 0.27.2, 0.27.3
Change log changelog.md
Dependencies base (>=4.7.0 && <5.0.0), bytestring (>=0.10.4 && <0.12.0), containers (>=0.4.2.1 && <0.7.0), file-embed (>=0.0.10 && <1.0.0), filepath (>=1.1.0 && <1.5.0), Glob (>=0.7.0 && <1.0.0), morpheus-graphql-client, morpheus-graphql-code-gen, morpheus-graphql-code-gen-utils (>=0.24.0 && <0.25.0), morpheus-graphql-core (>=0.24.0 && <0.25.0), morpheus-graphql-server (>=0.24.0 && <0.25.0), optparse-applicative (>=0.12.0 && <0.18.0), prettyprinter (>=1.7.0 && <2.0.0), relude (>=0.3.0 && <2.0.0), template-haskell (>=2.0.0 && <3.0.0), text (>=1.2.3 && <1.3.0), unordered-containers (>=0.2.8 && <0.3.0), yaml (>=0.8.32 && <1.0.0) [details]
License BSD-3-Clause
Copyright (c) 2019 Daviti Nalchevanidze
Author Daviti Nalchevanidze
Maintainer d.nalchevanidze@gmail.com
Category web, graphql, cli
Home page https://morpheusgraphql.com
Bug tracker https://github.com/morpheusgraphql/morpheus-graphql/issues
Source repo head: git clone https://github.com/morpheusgraphql/morpheus-graphql
Uploaded by nalchevanidze at 2022-10-21T22:07:35Z
Distributions
Reverse Dependencies 2 direct, 0 indirect [details]
Executables morpheus
Downloads 1853 total (81 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-10-21 [all 1 reports]

Readme for morpheus-graphql-code-gen-0.24.0

[back to package description]

Morpheus GraphQL Code Gen

Morpheus GraphQL Code Gen 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

Generating dummy Morpheus Api from schema.gql

morpheus build src/*.gql --root src

src/schema.gql

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

"""
deity description
"""
type Deity {
  """
  name description
  """
  name: String!
  power: String
}

src/Schema.hs

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}

module Schema where

import Data.Data (Typeable)
import Data.Map (empty, fromList)
import Data.Morpheus.Kind (TYPE)
import Data.Morpheus.Types
import Data.Text (Text)
import GHC.Generics (Generic)

---- GQL Query -------------------------------
data Query m = Query
  { queryDeity :: Arg "name" Text -> m (Maybe (Deity m)),
    queryDeities :: m [Deity m]
  }
  deriving (Generic)

instance (Typeable m) => GQLType (Query m) where
  type KIND (Query m) = TYPE

---- GQL Deity -------------------------------
data Deity m = Deity
  { deityName :: m Text,
    deityPower :: m (Maybe Text)
  }
  deriving (Generic)

instance (Typeable m) => GQLType (Deity m) where
  type KIND (Deity m) = TYPE
  description _ = Just "\ndeity description\n"
  getDescriptions _ = fromList [("name", "\n  name description\n  ")]