diff options
| author | Eugen Wissner <belka@caraus.de> | 2020-05-25 07:41:21 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2020-05-25 07:41:21 +0200 |
| commit | 61dbe6c7280a899b485146aa8557948417e78360 (patch) | |
| tree | 2b3bb2ea7144dd57a44076ab8f5af3321d5a95f1 /docs | |
| parent | eb90a4091c1f2586640ee49d6f91fc83c05239f6 (diff) | |
| download | graphql-61dbe6c7280a899b485146aa8557948417e78360.tar.gz | |
Split input/output types and values into 2 modules
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/tutorial/tutorial.lhs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/docs/tutorial/tutorial.lhs b/docs/tutorial/tutorial.lhs index c70c64c..e80e8c7 100644 --- a/docs/tutorial/tutorial.lhs +++ b/docs/tutorial/tutorial.lhs @@ -23,9 +23,9 @@ Since this file is a literate haskell file, we start by importing some dependenc > import Data.Time (getCurrentTime) > > import Language.GraphQL -> import Language.GraphQL.Type.Definition -> import Language.GraphQL.Type.Schema -> import qualified Language.GraphQL.Type as Type +> import Language.GraphQL.Trans +> import Language.GraphQL.Type +> import qualified Language.GraphQL.Type.Out as Out > > import Prelude hiding (putStrLn) @@ -42,10 +42,10 @@ First we build a GraphQL schema. > queryType :: ObjectType IO > queryType = ObjectType "Query" Nothing > $ HashMap.singleton "hello" -> $ Field Nothing (ScalarOutputType string) mempty hello +> $ Field Nothing (Out.NamedScalarType string) mempty hello > -> hello :: FieldResolver IO -> hello = NestingResolver $ pure $ Type.S "it's me" +> hello :: ActionT IO (Out.Value IO) +> hello = pure $ Out.String "it's me" This defines a simple schema with one type and one field, that resolves to a fixed value. @@ -77,12 +77,12 @@ For this example, we're going to be using time. > queryType2 :: ObjectType IO > queryType2 = ObjectType "Query" Nothing > $ HashMap.singleton "time" -> $ Field Nothing (ScalarOutputType string) mempty time +> $ Field Nothing (Out.NamedScalarType string) mempty time > -> time :: FieldResolver IO -> time = NestingResolver $ do +> time :: ActionT IO (Out.Value IO) +> time = do > t <- liftIO getCurrentTime -> pure $ Type.S $ Text.pack $ show t +> pure $ Out.String $ Text.pack $ show t This defines a simple schema with one type and one field, which resolves to the current time. @@ -140,8 +140,8 @@ Now that we have two resolvers, we can define a schema which uses them both. > > queryType3 :: ObjectType IO > queryType3 = ObjectType "Query" Nothing $ HashMap.fromList -> [ ("hello", Field Nothing (ScalarOutputType string) mempty hello) -> , ("time", Field Nothing (ScalarOutputType string) mempty time) +> [ ("hello", Field Nothing (Out.NamedScalarType string) mempty hello) +> , ("time", Field Nothing (Out.NamedScalarType string) mempty time) > ] > > query3 :: Text |
