Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- processRemoteJoins :: forall m. (MonadError QErr m, MonadIO m, MonadQueryTags m, MonadQueryLog m, MonadTrace m) => RequestId -> Logger Hasura -> Environment -> Manager -> [Header] -> UserInfo -> EncJSON -> Maybe RemoteJoins -> GQLReqUnparsed -> m EncJSON
- foldJoinTreeWith :: (MonadError QErr m, MonadQueryTags m, Traversable f) => (AnyBackend SourceJoinCall -> m ByteString) -> (ValidatedRemoteSchemaDef -> GQLReqOutgoing -> m ByteString) -> UserInfo -> f Value -> RemoteJoins -> m (f Value)
- forRemoteJoins :: Applicative f => Maybe RemoteJoins -> a -> (RemoteJoins -> f a) -> f a
- assignJoinIds :: JoinTree RemoteJoin -> JoinTree (JoinCallId, RemoteJoin)
- collectJoinArguments :: forall f m. (MonadError QErr m, Traversable f) => JoinTree (JoinCallId, RemoteJoin) -> f Value -> m (f (CompositeValue ReplacementToken), IntMap JoinArguments)
- joinResults :: forall f m. (MonadError QErr m, Traversable f) => IntMap (IntMap Value) -> f (CompositeValue ReplacementToken) -> m (f Value)
- type CompositeObject a = InsOrdHashMap Text (CompositeValue a)
- data CompositeValue a
- = CVOrdValue !Value
- | CVObject !(CompositeObject a)
- | CVObjectArray ![CompositeValue a]
- | CVFromRemote !a
- compositeValueToJSON :: CompositeValue Value -> Value
- data ReplacementToken = ReplacementToken {}
Documentation
processRemoteJoins :: forall m. (MonadError QErr m, MonadIO m, MonadQueryTags m, MonadQueryLog m, MonadTrace m) => RequestId -> Logger Hasura -> Environment -> Manager -> [Header] -> UserInfo -> EncJSON -> Maybe RemoteJoins -> GQLReqUnparsed -> m EncJSON Source #
Process all remote joins, recursively.
Given the result of the first step of an execution and its associated remote joins, process all joins recursively to build the resulting JSON object.
This function is a thin wrapper around processRemoteJoinsWith
, and starts
the join tree traversal process by re-parsing the EncJSON
value into an
introspectable JSON Value
, and "injects" the required functions to process
each join over the network.
:: (MonadError QErr m, MonadQueryTags m, Traversable f) | |
=> (AnyBackend SourceJoinCall -> m ByteString) | How to process a call to a source. |
-> (ValidatedRemoteSchemaDef -> GQLReqOutgoing -> m ByteString) | How to process a call to a remote schema. |
-> UserInfo | User information. |
-> f Value | Initial accumulator; the LHS of this join tree. |
-> RemoteJoins | |
-> m (f Value) |
Fold the join tree.
This function takes as an argument the functions that will be used to do the
actual network calls; this allows this function not to require MonadIO
,
allowing it to be used in tests.
forRemoteJoins :: Applicative f => Maybe RemoteJoins -> a -> (RemoteJoins -> f a) -> f a Source #
Simple convenient wrapper around Maybe RemoteJoins
.
assignJoinIds :: JoinTree RemoteJoin -> JoinTree (JoinCallId, RemoteJoin) Source #
When traversing a responses's json, wherever the join columns of a remote join are expected, we want to collect these arguments.
However looking up by a remote join's definition to collect these arguments
does not work because we don't have an Ord
or a Hashable
instance (it
would be a bit of work).
So this assigned each remote join a unique integer ID by using just the Eq
instance. This ID then can be used for the collection of arguments (which
should also be faster).
TODO(nicuveo): https://github.com/hasura/graphql-engine-mono/issues/3891.
collectJoinArguments :: forall f m. (MonadError QErr m, Traversable f) => JoinTree (JoinCallId, RemoteJoin) -> f Value -> m (f (CompositeValue ReplacementToken), IntMap JoinArguments) Source #
joinResults :: forall f m. (MonadError QErr m, Traversable f) => IntMap (IntMap Value) -> f (CompositeValue ReplacementToken) -> m (f Value) Source #
type CompositeObject a = InsOrdHashMap Text (CompositeValue a) Source #
data CompositeValue a Source #
A hybrid JSON value representation which captures the context of remote join field in type parameter.
CVOrdValue !Value | |
CVObject !(CompositeObject a) | |
CVObjectArray ![CompositeValue a] | |
CVFromRemote !a |
data ReplacementToken Source #
A token used to uniquely identify the results within a join call that are associated with a particular argument.
ReplacementToken | |
|