From 63d4de485d3cd96c00480dfe2e5a6cb320d520c7 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Sun, 1 Sep 2019 02:53:15 +0200 Subject: Deprecate enum, enumA, wrappedEnum, wrappedEnumA These functions are from Language.GraphQL.Schema. There are actually only two generic types in GraphQL: Scalars and objects. Enum is a scalar value. According to the specification enums may be serailized to strings. And in the current implementation they used untyped strings anyway, so there is no point to have differently named functions with the same implementation as their scalar counterparts. --- tests/Test/StarWars/Data.hs | 9 +++++---- tests/Test/StarWars/Schema.hs | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'tests/Test') diff --git a/tests/Test/StarWars/Data.hs b/tests/Test/StarWars/Data.hs index 55ff207..6a514c5 100644 --- a/tests/Test/StarWars/Data.hs +++ b/tests/Test/StarWars/Data.hs @@ -26,6 +26,7 @@ import Control.Monad.Trans.Except (throwE) import Data.Maybe (catMaybes) import Data.Text (Text) import Language.GraphQL.Trans +import Language.GraphQL.Type -- * Data -- See https://github.com/graphql/graphql-js/blob/master/src/__tests__/starWarsData.js @@ -190,8 +191,8 @@ getDroid' _ = empty getFriends :: Character -> [Character] getFriends char = catMaybes $ liftA2 (<|>) getDroid getHuman <$> friends char -getEpisode :: Alternative f => Int -> f Text -getEpisode 4 = pure "NEWHOPE" -getEpisode 5 = pure "EMPIRE" -getEpisode 6 = pure "JEDI" +getEpisode :: Int -> Maybe (Wrapping Text) +getEpisode 4 = pure $ Named "NEWHOPE" +getEpisode 5 = pure $ Named "EMPIRE" +getEpisode 6 = pure $ Named "JEDI" getEpisode _ = empty diff --git a/tests/Test/StarWars/Schema.hs b/tests/Test/StarWars/Schema.hs index 0a19085..f516f2a 100644 --- a/tests/Test/StarWars/Schema.hs +++ b/tests/Test/StarWars/Schema.hs @@ -12,6 +12,7 @@ import Control.Monad.Trans.Except (throwE) import Control.Monad.Trans.Class (lift) import Control.Monad.IO.Class (MonadIO(..)) import Data.List.NonEmpty (NonEmpty(..)) +import Data.Maybe (catMaybes) import qualified Language.GraphQL.Schema as Schema import Language.GraphQL.Trans import Language.GraphQL.Type @@ -50,7 +51,8 @@ character char = return , Schema.scalar "name" $ return $ name char , Schema.wrappedObject "friends" $ traverse character $ List $ Named <$> getFriends char - , Schema.enum "appearsIn" $ return $ foldMap getEpisode $ appearsIn char + , Schema.wrappedScalar "appearsIn" $ return . List + $ catMaybes (getEpisode <$> appearsIn char) , Schema.scalar "secretBackstory" $ secretBackstory char , Schema.scalar "homePlanet" $ return $ either mempty homePlanet char , Schema.scalar "__typename" $ return $ typeName char -- cgit v1.2.3