given this query
{
name,
userList {
firstName,
lastName
}
}
if userList (which is a list) is null for one object out of hundreds, I end up with this error
Value cannot be null. (Parameter 'source')
.
Shouldn't the GraphQL engine detect the null and just ignore it?
I've tried making the userList property nullable, but that doesn't help.
Here's the stack trace of the error:
at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)\r\n
at System.Linq.Enumerable.Select[TSource,TResult](IEnumerable`1 source, Func`2 selector)\r\n
at lambda_method961(Closure, OrganizationResponse)\r\n
at System.Linq.Enumerable.SelectIPartitionIterator`2.GetCount(Boolean onlyIfCheap)\r\n
at System.Linq.EnumerableExecutor`1.Execute()\r\n
at System.Linq.EnumerableQuery`1.System.Linq.IQueryProvider.Execute[TElement](Expression expression)\r\n
at HotChocolate.Types.Pagination.QueryableOffsetPagingHandler`1.<>c__DisplayClass3_0.<ResolveAsync>b__0()\r\n
at System.Threading.Tasks.Task`1.InnerInvoke()\r\n
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)\r\n
--- End of stack trace from previous location ---\r\n
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)\r\n
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)\r\n
--- End of stack trace from previous location ---\r\n
at HotChocolate.Types.Pagination.QueryableOffsetPagingHandler`1.ResolveAsync(IResolverContext context, IQueryable`1 source, OffsetPagingArguments arguments, CancellationToken cancellationToken)\r\n
at HotChocolate.Types.Pagination.OffsetPagingHandler.HotChocolate.Types.Pagination.IPagingHandler.SliceAsync(IResolverContext context, Object source)\r\n
at HotChocolate.Types.Pagination.PagingMiddleware.InvokeAsync(IMiddlewareContext context)\r\n
at HotChocolate.Utilities.MiddlewareCompiler`1.ExpressionHelper.AwaitTaskHelper(Task task)\r\n
at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken)\r\n
at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken)
This is solved by not using
[UseProjection]
on the operation. Especially since this is a REST call to another API, not a call to a database.