Skip to content

Cosmos IQueryable throws "LINQ query please set allowSynchronousQueryExecution true or use GetItemQueryIterator to execute asynchronously" #5958

@onionhammer

Description

@onionhammer

Is there an existing issue for this?

  • I have searched the existing issues

Product

Hot Chocolate

Describe the bug

When returning a Cosmos Linq Queryable, HotChocolate throws because it appears to be attempting to access the IQueryable synchronously (rather than async)

[UseFiltering]
public IQueryable<MyModel> GetPartner() =>
    MyContainer.GetItemLinqQueryable<MyModel>();

Steps to reproduce

  1. Connect your program to a cosmos database
  2. Return a queryable ala MyContainer.GetItemLinqQueryable()
  3. Exception happens when accessing that node

Relevant log output

GraphQL service exception for 'POST /graphql/UnknownOperation - 662a00b5500da5b6c5c6a01ee7142acd': To execute LINQ query please set allowSynchronousQueryExecution true or use GetItemQueryIterator to execute asynchronously
      System.NotSupportedException: To execute LINQ query please set allowSynchronousQueryExecution true or use GetItemQueryIterator to execute asynchronously
         at Microsoft.Azure.Cosmos.Linq.CosmosLinqQuery`1.GetEnumerator()+MoveNext()
         at HotChocolate.Execution.Processing.Tasks.ResolverTask.<>c__DisplayClass50_0.<ExecuteResolverPipelineAsync>b__0()
         at System.Threading.Tasks.Task`1.InnerInvoke()
         at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
      --- End of stack trace from previous location ---
         at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
         at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
      --- End of stack trace from previous location ---
         at HotChocolate.Execution.Processing.Tasks.ResolverTask.ExecuteResolverPipelineAsync(CancellationToken cancellationToken)
         at HotChocolate.Execution.Processing.Tasks.ResolverTask.TryExecuteAsync(CancellationToken cancellationToken)

Additional Context?

HC should try to load data from the IQuerayble asynchronously rather than synchronously

Version

13.0.5

Blockers to having a nice repository for searching/paging/filtering for Cosmos and HotChocolate

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DataIssue is related to filtering, sorting, pagination or projections🌶️ hot chocolate

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions