MIT licensed by Daviti Nalchevanidze
This version can be pinned in stack with:morpheus-graphql-app-0.20.1@sha256:d1d982fec3733aed41a80ac9d87b63d3cfeb9cffdac43d9dd540ad92ca423254,6927

Module documentation for 0.20.1

Morpheus GraphQL App

provides utilities for creating executable GraphQL applications for servers. You can use it to create a schema-first GraphQL server with dynamic typings.

Build schema-first GraphQL App with dynamic typings

schema.gql
type Deity {
  name: String
  power: [String!]
}

type Query {
  deity(id: ID): Deity
}
App.hs
deityResolver :: Monad m => NamedResolverFunction QUERY e m
deityResolver arg =
  object
    [ ("name", pure "Morpheus"),
      ("power", pure $ list [enum "Shapeshifting"])
    ]

resolver :: Monad m => RootResolverValue e m
resolver =
  queryResolvers
    [ ( "Query", const $ object [("deity", ref "Deity" <$> getArgument "id")]),
      ("Deity", deityResolver)
    ]

api :: ByteString -> IO  ByteString
api query = do
  schema <- LBS.readFile "./schema.gql" >>= resultOr (fail . show) pure . parseSchema
  runApp (mkApp schema resolver) query

Changes

Changelog

see latest changes on Github

0.19.0 - 21.03.2022

0.18.0 - 08.11.2021

0.17.0 (Initial Release) - 25.02.2021