Product
Hot Chocolate
Is your feature request related to a problem?
When using HotChocolate w/ ApolloFederation, if you try to add QueryContext as a parameter on a [ReferenceResolver] method, you get the following error when attempting to run a GraphQL query:
"extensions": {
"exception": {
"message": "No coercion operator is defined between types 'Subgraph.Entities.Employee' and 'Subgraph.Entities.EmployeeRelationshipEntity'.",
"stackTrace": "at System.Linq.Expressions.Expression.GetUserDefinedCoercionOrThrow(ExpressionType coercionType, Expression expression, Type convertToType)
at HotChocolate.Execution.Projections.SelectionExpressionBuilder.BuildTypeSwitchExpression(Context context, TypeContainer parent)
at HotChocolate.Execution.Projections.SelectionExpressionBuilder.BuildExpression[TRoot](Selection selection, UInt64 includeFlags)
at HotChocolate.Execution.Processing.<HotChocolateExecutionSelectionExtensions>FF70158D876F3061FDDBB9D1E7EDB0A5464CC82CDD650DA68B6E6D0205F91AFC7__Extensions.<>c__DisplayClass2_0`1.<GetOrCreateExpression>b__0()
at HotChocolate.Execution.Processing.OperationFeatureCollection.GetOrSetSafe[TFeature](Int32 selectionId, Func`1 factory)
at HotChocolate.Execution.Processing.SelectionFeatureCollection.GetOrSetSafe[TFeature](Func`1 factory)\r\n at HotChocolate.Execution.Processing.<HotChocolateExecutionSelectionExtensions>FF70158D876F3061FDDBB9D1E7EDB0A5464CC82CDD650DA68B6E6D0205F91AFC7__Extensions.GetOrCreateExpression[TValue](Selection selection)
at HotChocolate.Execution.Processing.HotChocolateExecutionSelectionExtensions.AsSelector[TValue](Selection selection, UInt64 includeFlags)
at HotChocolate.Data.QueryContextParameterExpressionBuilder.CreateQueryContext[T](IResolverContext context)
at lambda_method13(Closure, IResolverContext)
at HotChocolate.ApolloFederation.Resolvers.EntitiesResolver.ResolveEntityInternalAsync(FieldResolverDelegate resolver, IResolverContext context, ObjectType type, IValueNode representation)"
},
"service": "subgraph1"
}
The solution you'd like
I would like my reference resolvers to be able to take in the projected columns and pass that along to the data loader. If this is at all possible with ApolloFederation.
Example:
[ReferenceResolver]
public static async Task<Employee?> ResolveEmployee(int empId, QueryContext<Employee> query, IEmployeesByIdsDataLoader dataLoader, CancellationToken ct)
{
return await dataLoader.With(query).LoadAsync(empId, ct);
}
If I am doing this wrong currently, please advise me on the solution. Thank you.
Product
Hot Chocolate
Is your feature request related to a problem?
When using HotChocolate w/ ApolloFederation, if you try to add
QueryContextas a parameter on a[ReferenceResolver]method, you get the following error when attempting to run a GraphQL query:The solution you'd like
I would like my reference resolvers to be able to take in the projected columns and pass that along to the data loader. If this is at all possible with ApolloFederation.
Example:
If I am doing this wrong currently, please advise me on the solution. Thank you.