diff --git a/Data/GraphQL/Execute.hs b/Data/GraphQL/Execute.hs index 52537a4..fe78323 100644 --- a/Data/GraphQL/Execute.hs +++ b/Data/GraphQL/Execute.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE OverloadedStrings #-} -- | This module provides the function to execute a @GraphQL@ request -- -- according to a 'Schema'. module Data.GraphQL.Execute (execute) where @@ -7,6 +8,7 @@ import qualified Data.List.NonEmpty as NE import Data.List.NonEmpty (NonEmpty((:|))) import qualified Data.Aeson as Aeson +import qualified Data.HashMap.Strict as HashMap import qualified Data.GraphQL.AST as AST import qualified Data.GraphQL.AST.Core as AST.Core @@ -31,7 +33,8 @@ document _ _ = error "Multiple operations not supported yet" operation :: Alternative f => Schema f -> AST.Core.Operation -> f Aeson.Value operation schema (AST.Core.Query flds) = - Schema.resolve (NE.toList schema) (NE.toList flds) + Aeson.Object . HashMap.singleton "data" + <$> Schema.resolve (NE.toList schema) (NE.toList flds) operation _ _ = error "Mutations not supported yet" -- | Takes a variable substitution function and a @GraphQL@ document.