Skip to content

Why you do not use await in queries #6978

Answered by PascalSenn
dimitkos asked this question in Q&A
Discussion options

You must be logged in to vote

The return value from FirstOrDefaultAsync() is of type Task<Book?>, which means you do not need to await it since it matches the expected return type.

As a result, an async state machine is not compiled around it.

However, you can still use async and await if you prefer.
The difference is negligible, and Hot Chocolate understands both approaches.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by dimitkos
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants