-
-
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 node resolver and entities resolver (#5080)
- Loading branch information
1 parent
6126488
commit 88bc2c6
Showing
3 changed files
with
118 additions
and
13 deletions.
There are no files selected for viewing
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
111 changes: 111 additions & 0 deletions
111
src/HotChocolate/Core/src/Types/Types/Helpers/ResolverContextProxy.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,111 @@ | ||
#nullable enable | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Threading; | ||
using HotChocolate.Language; | ||
using HotChocolate.Resolvers; | ||
using HotChocolate.Types; | ||
|
||
namespace HotChocolate.Execution; | ||
|
||
internal sealed class ResolverContextProxy : IResolverContext | ||
{ | ||
private readonly IResolverContext _resolverContext; | ||
|
||
public ResolverContextProxy(IResolverContext resolverContext) | ||
{ | ||
_resolverContext = resolverContext; | ||
ScopedContextData = resolverContext.ScopedContextData; | ||
LocalContextData = resolverContext.LocalContextData; | ||
} | ||
|
||
public IDictionary<string, object?> ContextData => _resolverContext.ContextData; | ||
|
||
public ISchema Schema => _resolverContext.Schema; | ||
|
||
public IObjectType RootType => _resolverContext.RootType; | ||
|
||
public IObjectType ObjectType => _resolverContext.ObjectType; | ||
|
||
public IServiceProvider Services | ||
{ | ||
get => _resolverContext.Services; | ||
set => _resolverContext.Services = value; | ||
} | ||
|
||
[Obsolete] | ||
public IObjectField Field => _resolverContext.Field; | ||
|
||
public DocumentNode Document => _resolverContext.Document; | ||
|
||
public OperationDefinitionNode Operation => _resolverContext.Operation; | ||
|
||
[Obsolete] | ||
public FieldNode FieldSelection => _resolverContext.FieldSelection; | ||
|
||
public NameString ResponseName => _resolverContext.ResponseName; | ||
|
||
public Path Path => _resolverContext.Path; | ||
|
||
public bool HasErrors => _resolverContext.HasErrors; | ||
|
||
public IFieldSelection Selection => _resolverContext.Selection; | ||
|
||
public IVariableValueCollection Variables => _resolverContext.Variables; | ||
|
||
|
||
public IImmutableDictionary<string, object?> ScopedContextData | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
public IImmutableDictionary<string, object?> LocalContextData | ||
{ | ||
get; | ||
set; | ||
} | ||
|
||
public CancellationToken RequestAborted => _resolverContext.RequestAborted; | ||
|
||
[Obsolete("Use ArgumentValue<T>(name) or " + | ||
"ArgumentLiteral<TValueNode>(name) or " + | ||
"ArgumentOptional<T>(name).")] | ||
public T? Argument<T>(NameString name) => _resolverContext.Argument<T>(name); | ||
|
||
public object Service(Type service) => _resolverContext.Service(service); | ||
|
||
public void ReportError(string errorMessage) => _resolverContext.ReportError(errorMessage); | ||
|
||
public void ReportError(IError error) => _resolverContext.ReportError(error); | ||
|
||
public void ReportError(Exception exception, Action<IErrorBuilder>? configure = null) | ||
=> _resolverContext.ReportError(exception, configure); | ||
|
||
public IReadOnlyList<IFieldSelection> GetSelections( | ||
ObjectType typeContext, | ||
SelectionSetNode? selectionSet = null, | ||
bool allowInternals = false) | ||
=> _resolverContext.GetSelections(typeContext, selectionSet, allowInternals); | ||
|
||
public T GetQueryRoot<T>() | ||
=> _resolverContext.GetQueryRoot<T>(); | ||
|
||
public T Parent<T>() => _resolverContext.Parent<T>(); | ||
|
||
public T ArgumentValue<T>(NameString name) => _resolverContext.ArgumentValue<T>(name); | ||
|
||
public TValueNode ArgumentLiteral<TValueNode>(NameString name) | ||
where TValueNode : IValueNode | ||
=> _resolverContext.ArgumentLiteral<TValueNode>(name); | ||
|
||
public Optional<T> ArgumentOptional<T>(NameString name) | ||
=> _resolverContext.ArgumentOptional<T>(name); | ||
|
||
public ValueKind ArgumentKind(NameString name) => _resolverContext.ArgumentKind(name); | ||
|
||
public T Service<T>() => _resolverContext.Service<T>(); | ||
|
||
public T Resolver<T>() => _resolverContext.Resolver<T>(); | ||
} |
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