Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data ResolverError
- class HasResolver m a where
- type Handler m a
- data a :<> b = a :<> b
- data Result a = Result [ResolverError] a
- unionValue :: forall (object :: Type) (union :: Type) m (name :: Symbol) interfaces fields. (Monad m, Object name interfaces fields ~ object, KnownSymbol name) => TypeIndex m object union -> m (DynamicUnionValue union m)
Documentation
data ResolverError Source #
SchemaError NameError | There was a problem in the schema. Server-side problem. |
FieldNotFoundError Name | Couldn't find the requested field in the object. A client-side problem. |
ValueMissing Name | No value provided for name, and no default specified. Client-side problem. |
InvalidValue Name Text | Could not translate value into Haskell. Probably a client-side problem. |
ValidationError ValidationErrors | Found validation errors when we tried to merge fields. |
SubSelectionOnLeaf (SelectionSetByType Value) | Tried to get subselection of leaf field. |
MissingSelectionSet | Tried to treat an object as a leaf. |
class HasResolver m a where Source #
Applicative m => HasResolver * m Bool Source # | |
Applicative m => HasResolver * m Text Source # | |
Applicative m => HasResolver * m Double Source # | |
Applicative m => HasResolver * m Int32 Source # | |
(HasResolver * m hg, Monad m) => HasResolver * m (Maybe hg) Source # | |
(Monad m, Applicative m, HasResolver Type m hg) => HasResolver * m (List hg) Source # | |
(Monad m, KnownSymbol unionName, RunUnion [Type] m (Union unionName objects) objects) => HasResolver * m (Union unionName objects) Source # | |
(Applicative m, GraphQLEnum enum) => HasResolver * m (Enum ksN enum) Source # | |
(RunFields m (RunFieldsType m fields), HasObjectDefinition * (Object typeName interfaces fields), Monad m) => HasResolver * m (Object typeName interfaces fields) Source # | |
data a :<> b infixr 8 Source #
Object field separation operator.
Use this to provide handlers for fields of an object.
Say you had the following GraphQL type with "foo" and "bar" fields, e.g.
type MyObject { foo: Int! bar: String! }
You could provide handlers for it like this:
>>>
:m +System.Environment
>>>
let fooHandler = pure 42
>>>
let barHandler = System.Environment.getProgName
>>>
let myObjectHandler = pure $ fooHandler :<> barHandler :<> ()
a :<> b infixr 8 |
Result [ResolverError] a |
unionValue :: forall (object :: Type) (union :: Type) m (name :: Symbol) interfaces fields. (Monad m, Object name interfaces fields ~ object, KnownSymbol name) => TypeIndex m object union -> m (DynamicUnionValue union m) Source #
Translate a Handler
into a DynamicUnionValue type required by
Union
handlers. This is dynamic, but nevertheless type-safe
because we can only tag with types that are part of the union.
Use e.g. like "unionValue @Cat" if you have an object like this:
>>>
type Cat = API.Object "Cat" '[] '[API.Field "name" Text]
and then use `unionValue @Cat (pure (pure Felix))`. See `examples/UnionExample.hs` for more code.