Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
How to construct and execute a call to a source for a remote join.
There are three steps required to do this: - construct the execution step for that source join - execute that GraphQL query over the network - build a join index of the variables out of the response
This can be done as one function, but we also export the individual steps for
debugging / test purposes. We congregate all intermediary state in the opaque
SourceJoinCall
type.
Synopsis
- makeSourceJoinCall :: (MonadQueryTags m, MonadError QErr m, MonadTrace m, MonadIO m) => (AnyBackend SourceJoinCall -> m ByteString) -> UserInfo -> AnyBackend RemoteSourceJoin -> FieldName -> IntMap JoinArgument -> [Header] -> Maybe Name -> m (Maybe (IntMap Value))
- data SourceJoinCall b = SourceJoinCall {}
- buildSourceJoinCall :: forall b m. (BackendExecute b, MonadQueryTags m, MonadError QErr m, MonadTrace m, MonadIO m) => UserInfo -> FieldName -> IntMap JoinArgument -> [Header] -> Maybe Name -> RemoteSourceJoin b -> m (Maybe (AnyBackend SourceJoinCall))
- buildJoinIndex :: MonadError QErr m => ByteString -> m (IntMap Value)
Documentation
:: (MonadQueryTags m, MonadError QErr m, MonadTrace m, MonadIO m) | |
=> (AnyBackend SourceJoinCall -> m ByteString) | Function to dispatch a request to a source. |
-> UserInfo | User information. |
-> AnyBackend RemoteSourceJoin | Remote join information. |
-> FieldName | Name of the field from the join arguments. |
-> IntMap JoinArgument | Mapping from |
-> [Header] | |
-> Maybe Name | |
-> m (Maybe (IntMap Value)) | The resulting join index (see |
Construct and execute a call to a source for a remote join.
data SourceJoinCall b Source #
Intermediate type that contains all the necessary information to perform a call to a database to perform a join.
buildSourceJoinCall :: forall b m. (BackendExecute b, MonadQueryTags m, MonadError QErr m, MonadTrace m, MonadIO m) => UserInfo -> FieldName -> IntMap JoinArgument -> [Header] -> Maybe Name -> RemoteSourceJoin b -> m (Maybe (AnyBackend SourceJoinCall)) Source #
buildJoinIndex :: MonadError QErr m => ByteString -> m (IntMap Value) Source #
Construct a join index from the EncJSON
response from the source.
Unlike with remote schemas, we can make assumptions about the shape of the
result, instead of having to keep track of the path within the answer. This
function therefore enforces that the answer has the shape we expect, and
throws a QErr
if it doesn't.