28 lines
920 B
Haskell
28 lines
920 B
Haskell
|
module Language.GraphQL.Reflection (toType) where
|
||
|
|
||
|
import Language.GraphQL.AST as GraphQL
|
||
|
import Data.List.NonEmpty (NonEmpty)
|
||
|
import qualified Language.Haskell.Exts.Syntax as Haskell
|
||
|
|
||
|
toType :: GraphQL.Document -> NonEmpty (Haskell.Decl a)
|
||
|
toType = document
|
||
|
|
||
|
document :: GraphQL.Document -> NonEmpty (Haskell.Decl a)
|
||
|
document = fmap definition
|
||
|
|
||
|
definition :: GraphQL.Definition -> Haskell.Decl a
|
||
|
definition = \case
|
||
|
DefinitionOperation def -> definitionOperation def
|
||
|
DefinitionFragment def -> definitionFragment def
|
||
|
|
||
|
definitionOperation :: OperationDefinition -> Haskell.Decl a
|
||
|
definitionOperation = \case
|
||
|
OperationSelectionSet op -> selectionSet op
|
||
|
OperationDefinition{} -> undefined
|
||
|
|
||
|
selectionSet :: SelectionSet -> Haskell.Decl a
|
||
|
selectionSet = undefined
|
||
|
|
||
|
definitionFragment :: FragmentDefinition -> Haskell.Decl a
|
||
|
definitionFragment (FragmentDefinition fragmentName typeCondition directive selectionSet) = _
|