Split input/output types and values into 2 modules

This commit is contained in:
2020-05-25 07:41:21 +02:00
parent eb90a4091c
commit 61dbe6c728
16 changed files with 325 additions and 308 deletions

View File

@ -14,27 +14,27 @@ import Language.GraphQL.Type.Definition
import qualified Language.GraphQL.Type.Out as Out
import Language.GraphQL.Type.Schema
hatType :: ObjectType IO
hatType = ObjectType "Hat" Nothing
hatType :: Out.ObjectType IO
hatType = Out.ObjectType "Hat" Nothing
$ HashMap.singleton resolverName
$ Field Nothing (ScalarOutputType int) mempty resolve
$ Out.Field Nothing (Out.NamedScalarType int) mempty resolve
where
(Schema.Resolver resolverName resolve) =
Schema.Resolver "circumference" $ pure $ Out.Int 60
schema :: Schema IO
schema = Schema
(ObjectType "Query" Nothing hatField)
(Just $ ObjectType "Mutation" Nothing incrementField)
(Out.ObjectType "Query" Nothing hatField)
(Just $ Out.ObjectType "Mutation" Nothing incrementField)
where
garment = pure $ Schema.object
[ Schema.Resolver "circumference" $ pure $ Out.Int 60
]
incrementField = HashMap.singleton "incrementCircumference"
$ Field Nothing (ScalarOutputType int) mempty
$ Out.Field Nothing (Out.NamedScalarType int) mempty
$ pure $ Out.Int 61
hatField = HashMap.singleton "garment"
$ Field Nothing (ObjectOutputType hatType) mempty garment
$ Out.Field Nothing (Out.NamedObjectType hatType) mempty garment
spec :: Spec
spec =