-
-
Notifications
You must be signed in to change notification settings - Fork 748
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed projections with multiple interceptors. (#2836)
- Loading branch information
1 parent
bb459e3
commit 14f799f
Showing
5 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
src/HotChocolate/Data/src/Data/Projections/Convention/ProjectionInterceptorCombinator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using HotChocolate.Execution.Processing; | ||
|
||
namespace HotChocolate.Data.Projections.Handlers | ||
{ | ||
/// <summary> | ||
/// This wrapper is used to combined two interceptors and create a chain | ||
/// </summary> | ||
internal class ProjectionInterceptorCombinator<T> | ||
: IProjectionFieldInterceptor<T> | ||
where T : IProjectionVisitorContext | ||
{ | ||
private readonly IProjectionFieldInterceptor _current; | ||
private readonly IProjectionFieldInterceptor _next; | ||
|
||
public ProjectionInterceptorCombinator( | ||
IProjectionFieldInterceptor current, | ||
IProjectionFieldInterceptor next) | ||
{ | ||
_current = current; | ||
_next = next; | ||
} | ||
|
||
public bool CanHandle(ISelection selection) => true; | ||
|
||
public void BeforeProjection( | ||
T context, | ||
ISelection selection) | ||
{ | ||
if (_current is IProjectionFieldInterceptor<T> currentHandler) | ||
{ | ||
currentHandler.BeforeProjection(context, selection); | ||
} | ||
|
||
if (_next is IProjectionFieldInterceptor<T> nextHandler) | ||
{ | ||
nextHandler.BeforeProjection(context, selection); | ||
} | ||
} | ||
|
||
public void AfterProjection(T context, ISelection selection) | ||
{ | ||
if (_next is IProjectionFieldInterceptor<T> nextHandler) | ||
{ | ||
nextHandler.AfterProjection(context, selection); | ||
} | ||
|
||
if (_current is IProjectionFieldInterceptor<T> currentHandler) | ||
{ | ||
currentHandler.AfterProjection(context, selection); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters