diff options
| author | Danny Navarro <j@dannynavarro.net> | 2017-02-10 18:40:08 -0300 |
|---|---|---|
| committer | Danny Navarro <j@dannynavarro.net> | 2017-02-10 17:10:09 -0300 |
| commit | e716bc57e786e1d9b733c3a2782fdf27007b3e23 (patch) | |
| tree | ca078abe32bdf9810231dd4081dff5ab88cbfde9 /Data/GraphQL/Execute.hs | |
| parent | 4ab4660d364cc62c9e23d2cdc85abc3f7dc6dc8d (diff) | |
| download | graphql-e716bc57e786e1d9b733c3a2782fdf27007b3e23.tar.gz | |
Wrap executed result in "data" object
Diffstat (limited to 'Data/GraphQL/Execute.hs')
| -rw-r--r-- | Data/GraphQL/Execute.hs | 5 |
1 files changed, 4 insertions, 1 deletions
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. |
