Wrap executed result in "data" object
This commit is contained in:
parent
4ab4660d36
commit
e716bc57e7
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user