haskell-graphql / graphql-api

Write type-safe GraphQL services in Haskell
BSD 3-Clause "New" or "Revised" License
406 stars 35 forks source link

"Input" API for parsing, validating and normalizing graphql queries #21

Closed teh closed 7 years ago

teh commented 7 years ago

The following bit of code:

import qualified Data.GraphQL.AST as AST
import Data.GraphQL.Parser (document)
import GraphQL.Value (Value)
import Data.Attoparsec.Text (parseOnly, endOfInput)

query :: Text -> AST.SelectionSet
query q =
  let Right (AST.Document [AST.DefinitionOperation (AST.Query (AST.Node _ _ _ selectionSet))]) =
       parseOnly (document <* endOfInput) q
  in selectionSet

could got into a function that returns a CanonicalQuery (whose type we can refine at a later stage).

jml commented 7 years ago

Going to track the rest of the bits of this in more specific tickets.