You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 898 B

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Morpheus GraphQL Core
  2. core Functionalities of Morpheus GraphQL, can be used to build GraphQL server, client ..
  3. - parser
  4. - validar
  5. - api
  6. ## Build GraphQL api with Core
  7. ```hs
  8. schema :: Schema VALID
  9. schema =
  10. [dsl|
  11. type Query {
  12. deity(name: String): Deity!
  13. }
  14. type Deity {
  15. name: String!
  16. power: [String!]!
  17. }
  18. |]
  19. resolver :: Monad m => RootResModel e m
  20. resolver =
  21. RootResModel
  22. { query =
  23. pure $
  24. mkObject
  25. "Query"
  26. [("deity", resolveDeity)],
  27. mutation = pure mkNull,
  28. subscription = pure mkNull
  29. }
  30. resolveDeity :: (WithOperation o, Monad m) => Resolver o e m (ResModel o e m)
  31. resolveDeity =
  32. pure $
  33. mkObject
  34. "Deity"
  35. [ ("name", pure $ mkString "Morpheus"),
  36. ("power", pure $ mkList [mkString "Shapeshifting"])
  37. ]
  38. api :: ByteString -> IO ByteString
  39. api = runApp (mkApp schema resolver)
  40. ```