From df8e43c9aa922ff8f3ce1bf560c4286012486907 Mon Sep 17 00:00:00 2001 From: Danny Navarro Date: Tue, 9 Feb 2016 13:31:28 +0100 Subject: Handle Output enumerations in Schema definition The third end-to-end test from graphql-js was implemented. --- Data/GraphQL/Execute.hs | 3 +++ Data/GraphQL/Schema.hs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'Data') diff --git a/Data/GraphQL/Execute.hs b/Data/GraphQL/Execute.hs index df6b506..0586a2e 100644 --- a/Data/GraphQL/Execute.hs +++ b/Data/GraphQL/Execute.hs @@ -33,6 +33,9 @@ selection _ _ = error "selection: Not implemented yet" output :: (Alternative f, Monad f) => SelectionSet -> Output f -> f Aeson.Value output sels (OutputResolver resolv) = selectionSet resolv sels output sels (OutputList os) = fmap array . traverse (output sels) =<< os +output sels (OutputEnum e) + | null sels = Aeson.toJSON <$> e + | otherwise = empty output sels (OutputScalar s) | null sels = Aeson.toJSON <$> s | otherwise = empty diff --git a/Data/GraphQL/Schema.hs b/Data/GraphQL/Schema.hs index a4ba0ca..8a6e625 100644 --- a/Data/GraphQL/Schema.hs +++ b/Data/GraphQL/Schema.hs @@ -14,8 +14,8 @@ type Resolver f = Input -> f (Output f) data Output f = OutputResolver (Resolver f) | OutputList (f [Output f]) | OutputScalar (f Scalar) + | OutputEnum (f Text) -- | OutputUnion [Output] - -- | OutputEnum [Scalar] -- | OutputNonNull (Output) data Input = InputScalar Scalar -- cgit v1.2.3