Cosmos IQueryable throws "LINQ query please set allowSynchronousQueryExecution true or use GetItemQueryIterator to execute asynchronously"
See original GitHub issueIs 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
- Connect your program to a cosmos database
- Return a queryable ala MyContainer.GetItemLinqQueryable<MyModel>()
- 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
Issue Analytics
- State:
- Created 6 months ago
- Comments:16 (14 by maintainers)
Top Results From Across the Web
How to do run LINQ Count on a Cosmos-db query ...
I have an existing Cosmos-db SDK V3 query in my C# code and I can run the Count method on it if "...
Read more >Container.GetItemLinqQueryable<T> Method
This method creates a LINQ query for items under a container in an Azure Cosmos DB service. IQueryable extension method ToFeedIterator() should be...
Read more >LINQ to NoSQL translation - Azure Cosmos DB
Learn the LINQ operators supported and how the LINQ queries are mapped to ... shows LINQ query generation and asynchronous execution with a...
Read more >Query Document using LINQ on Azure Cosmos DB
Either you query XML or File or Object you always write a same program. You can create an IQueryable object that directly queries...
Read more >Using LINQ to Query Dynamic Schema-less Cosmos DB ...
On July 9, 2019, a new set of libraries for working with Azure services was announced. These SDKs target multiple languages including Python, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m new to this library and also very much invested in CosmosDB. Can anyone tell me if this is a bad approach to fixing the OPs error
It does work without the
allowSynchronousQueryExecution
set to true.We have a standard template for this. I can post you later a pr that shows how such a driver is implemented.