Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- getRemoteJoinsQueryDB :: Backend b => QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> (QueryDB b Void (UnpreparedValue b), Maybe RemoteJoins)
- getRemoteJoinsMutationDB :: Backend b => MutationDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> (MutationDB b Void (UnpreparedValue b), Maybe RemoteJoins)
- getRemoteJoinsActionQuery :: ActionQuery (RemoteRelationshipField UnpreparedValue) -> (ActionQuery Void, Maybe RemoteJoins)
- getRemoteJoinsActionMutation :: ActionMutation (RemoteRelationshipField UnpreparedValue) -> (ActionMutation Void, Maybe RemoteJoins)
- getRemoteJoinsSourceRelation :: Backend b => SourceRelationshipSelection b (RemoteRelationshipField UnpreparedValue) UnpreparedValue -> (SourceRelationshipSelection b Void UnpreparedValue, Maybe RemoteJoins)
- getRemoteJoinsGraphQLField :: GraphQLField (RemoteRelationshipField UnpreparedValue) var -> (GraphQLField Void var, Maybe RemoteJoins)
- getRemoteJoinsGraphQLSelectionSet :: SelectionSet (RemoteRelationshipField UnpreparedValue) var -> (SelectionSet Void var, Maybe RemoteJoins)
- newtype Collector a = Collector {
- runCollector :: (a, Maybe RemoteJoins)
- collect :: NEHashMap QualifiedFieldName RemoteJoin -> Collector ()
- withField :: Maybe Text -> Text -> Collector a -> Collector a
- traverseFields :: (a -> Collector b) -> Fields a -> Collector (Fields b)
- transformAsyncFields :: AsyncActionQueryFieldG (RemoteRelationshipField UnpreparedValue) -> Collector (AsyncActionQueryFieldG Void)
- transformMutationOutput :: Backend b => MutationOutputG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (MutationOutputG b Void (UnpreparedValue b))
- transformSyncAction :: AnnActionExecution (RemoteRelationshipField UnpreparedValue) -> Collector (AnnActionExecution Void)
- transformSelect :: Backend b => AnnSimpleSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (AnnSimpleSelectG b Void (UnpreparedValue b))
- transformStreamSelect :: Backend b => AnnSimpleStreamSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (AnnSimpleStreamSelectG b Void (UnpreparedValue b))
- transformAggregateSelect :: Backend b => AnnAggregateSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (AnnAggregateSelectG b Void (UnpreparedValue b))
- transformConnectionSelect :: forall b. Backend b => ConnectionSelect b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (ConnectionSelect b Void (UnpreparedValue b))
- transformObjectSelect :: Backend b => AnnObjectSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (AnnObjectSelectG b Void (UnpreparedValue b))
- transformGraphQLField :: GraphQLField (RemoteRelationshipField UnpreparedValue) var -> Collector (GraphQLField Void var)
- transformGraphQLSelectionSet :: SelectionSet (RemoteRelationshipField UnpreparedValue) var -> Collector (SelectionSet Void var)
- transformAnnFields :: forall src. Backend src => AnnFieldsG src (RemoteRelationshipField UnpreparedValue) (UnpreparedValue src) -> Collector (AnnFieldsG src Void (UnpreparedValue src))
- transformActionFields :: ActionFieldsG (RemoteRelationshipField UnpreparedValue) -> Collector ActionFields
- transformObjectSelectionSet :: Maybe Name -> ObjectSelectionSet (RemoteRelationshipField UnpreparedValue) var -> Collector (ObjectSelectionSet Void var)
- createRemoteJoin :: HashMap FieldName JoinColumnAlias -> RemoteRelationshipField UnpreparedValue -> RemoteJoin
- getJoinColumnAlias :: (Eq field, Hashable field) => FieldName -> field -> HashMap field FieldName -> [FieldName] -> JoinColumnAlias
- getFields :: Traversal' super sub -> [(any, super)] -> [(any, sub)]
Documentation
getRemoteJoinsQueryDB :: Backend b => QueryDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> (QueryDB b Void (UnpreparedValue b), Maybe RemoteJoins) Source #
getRemoteJoinsMutationDB :: Backend b => MutationDB b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> (MutationDB b Void (UnpreparedValue b), Maybe RemoteJoins) Source #
Collects remote joins from the a MutationDB
if any, and transforms the
selection to add new join fields where those occured.
Returns the transformed selection set, in which remote fields have been
inserted, and for which the r
type is now Void
.
getRemoteJoinsActionQuery :: ActionQuery (RemoteRelationshipField UnpreparedValue) -> (ActionQuery Void, Maybe RemoteJoins) Source #
getRemoteJoinsActionMutation :: ActionMutation (RemoteRelationshipField UnpreparedValue) -> (ActionMutation Void, Maybe RemoteJoins) Source #
getRemoteJoinsSourceRelation :: Backend b => SourceRelationshipSelection b (RemoteRelationshipField UnpreparedValue) UnpreparedValue -> (SourceRelationshipSelection b Void UnpreparedValue, Maybe RemoteJoins) Source #
getRemoteJoinsGraphQLField :: GraphQLField (RemoteRelationshipField UnpreparedValue) var -> (GraphQLField Void var, Maybe RemoteJoins) Source #
getRemoteJoinsGraphQLSelectionSet :: SelectionSet (RemoteRelationshipField UnpreparedValue) var -> (SelectionSet Void var, Maybe RemoteJoins) Source #
A writer monad used to collect together all remote joins appearing in some data structure.
In the functions below, the withField
function is used to track the
context of the path from the root of the current selection set.
It is important that we work bottom-up, and do not collect
duplicate
field names at any level, because the Semigroup
instance for RemoteJoins
does not allow for these duplicates.
Collector | |
|
collect :: NEHashMap QualifiedFieldName RemoteJoin -> Collector () Source #
Collect some remote joins appearing at the given field names in the current context.
withField :: Maybe Text -> Text -> Collector a -> Collector a Source #
Keep track of the given field name in the current path from the root of the selection set.
traverseFields :: (a -> Collector b) -> Fields a -> Collector (Fields b) Source #
Traverse a list of fields, while applying withField
to keep track of the
path within the AST. This function assumes that no type name is required for
the QualifiedFieldName
and uses Nothing
.
transformAsyncFields :: AsyncActionQueryFieldG (RemoteRelationshipField UnpreparedValue) -> Collector (AsyncActionQueryFieldG Void) Source #
transformMutationOutput :: Backend b => MutationOutputG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (MutationOutputG b Void (UnpreparedValue b)) Source #
transformSyncAction :: AnnActionExecution (RemoteRelationshipField UnpreparedValue) -> Collector (AnnActionExecution Void) Source #
transformSelect :: Backend b => AnnSimpleSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (AnnSimpleSelectG b Void (UnpreparedValue b)) Source #
transformStreamSelect :: Backend b => AnnSimpleStreamSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (AnnSimpleStreamSelectG b Void (UnpreparedValue b)) Source #
transformAggregateSelect :: Backend b => AnnAggregateSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (AnnAggregateSelectG b Void (UnpreparedValue b)) Source #
transformConnectionSelect :: forall b. Backend b => ConnectionSelect b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (ConnectionSelect b Void (UnpreparedValue b)) Source #
transformObjectSelect :: Backend b => AnnObjectSelectG b (RemoteRelationshipField UnpreparedValue) (UnpreparedValue b) -> Collector (AnnObjectSelectG b Void (UnpreparedValue b)) Source #
transformGraphQLField :: GraphQLField (RemoteRelationshipField UnpreparedValue) var -> Collector (GraphQLField Void var) Source #
transformGraphQLSelectionSet :: SelectionSet (RemoteRelationshipField UnpreparedValue) var -> Collector (SelectionSet Void var) Source #
transformAnnFields :: forall src. Backend src => AnnFieldsG src (RemoteRelationshipField UnpreparedValue) (UnpreparedValue src) -> Collector (AnnFieldsG src Void (UnpreparedValue src)) Source #
Transforms a source selection set.
This function takes an AnnFieldsG
, which corresponds to a selection of
fields on a source, and extracts remote joins: for every field we encounter
that maps to a remote destination (either another source or a remote schema),
we replace it with a phantom field and collect
the corresponding
RemoteJoin
.
transformActionFields :: ActionFieldsG (RemoteRelationshipField UnpreparedValue) -> Collector ActionFields Source #
Transforms an action's selection set.
This function takes an ActionFieldsG
, which corresponds to a selection of
fields on the result of an action, and extracts remote joins: for every field
we encounter that maps to a remote destination (either a source or a remote
schema), we replace it with a phantom field and collect
the corresponding
RemoteJoin
.
transformObjectSelectionSet Source #
:: Maybe Name | The type name on which this selection set is defined; this is only
expected to be provided for unions and interfaces, not for regular objects,
as this is used to determine whether a selection set is potentially
"ambiguous" or not, and regular objects cannot. This will be used as the
type name in the |
-> ObjectSelectionSet (RemoteRelationshipField UnpreparedValue) var | |
-> Collector (ObjectSelectionSet Void var) |
Transforms a GraphQL selection set.
This function takes an SelectionSet
, which corresponds to a selection of
fields on a remote GraphQL schema, and extracts remote joins: for every field
we encounter that maps to a remote destination (either a source or another
remote schema), we replace it with a phantom field and collect
the
corresponding RemoteJoin
.
createRemoteJoin :: HashMap FieldName JoinColumnAlias -> RemoteRelationshipField UnpreparedValue -> RemoteJoin Source #
Converts a remote relationship field into a RemoteJoin
that
the execution engine understands.
getJoinColumnAlias :: (Eq field, Hashable field) => FieldName -> field -> HashMap field FieldName -> [FieldName] -> JoinColumnAlias Source #
Constructs a JoinColumnAlias
for a given field in a selection set.
If the field was already requested, we leave it unchanged, to avoid double-fetching the same information. However, if this field is a "phantom" field, that we only add for the purpose of fetching a join key, we rename it in a way that is guaranteed to avoid conflicts.
NOTE: if the fieldName
argument is a valid GraphQL name, then the
constructed alias MUST also be a valid GraphQL name.