41 lines
1.2 KiB
Haskell
41 lines
1.2 KiB
Haskell
|
module Main where
|
||
|
|
||
|
import qualified Language.GraphQL.Parser as GraphQL
|
||
|
import qualified Language.GraphQL.AST as GraphQL
|
||
|
import qualified Language.GraphQL.Reflection as GraphQL
|
||
|
import qualified Data.Text.IO as Text
|
||
|
import Text.Megaparsec (ParseErrorBundle)
|
||
|
import qualified Text.Megaparsec as Parsec
|
||
|
import qualified System.Environment as System
|
||
|
import qualified Language.Haskell.Exts.Syntax as Haskell
|
||
|
import Data.Foldable (traverse_)
|
||
|
import Control.Monad ((>=>))
|
||
|
import Control.Category ((>>>))
|
||
|
import qualified Language.Haskell.Exts.Syntax as Haskell
|
||
|
import Data.List.NonEmpty (NonEmpty)
|
||
|
import Control.Exception
|
||
|
|
||
|
main :: IO ()
|
||
|
main = print doc
|
||
|
where
|
||
|
doc :: GraphQL.Document
|
||
|
doc = Parsec.parseMaybe GraphQL.document "<nothing>"
|
||
|
-- main :: IO ()
|
||
|
-- main = System.getArgs >>= traverse_ run
|
||
|
|
||
|
run :: FilePath -> IO ()
|
||
|
run = parse >=> (GraphQL.toType >>> print @(NonEmpty (Haskell.Decl ())))
|
||
|
|
||
|
parse :: FilePath -> IO GraphQL.Document
|
||
|
parse p = do
|
||
|
txt <- Text.readFile p
|
||
|
either badFailureMechanism pure $ Parsec.parse GraphQL.document p txt
|
||
|
where
|
||
|
badFailureMechanism = fail . displayException
|
||
|
|
||
|
getExample :: IO GraphQL.Document
|
||
|
getExample = parse p
|
||
|
where
|
||
|
p :: FilePath
|
||
|
p = "/Users/frederikhanghjiversen/git/zendesk/guide-graph/schema/schema.graphql"
|