Document an example of async usage?
See original GitHub issueI’m not an expert in the python ecosystem, and am not sure what’s required from me to support asynchronous resolvers in an Ariadne schema. If it’s possible, I’d love a brief example illustrating a working async resolver!
What I’ve tried so far (using python 3.7):
from aiodataloader import DataLoader
from ariadne import ResolverMap, gql, start_simple_server
# DATA LOADERS
heroesLoader = HeroesLoader()
class HeroesLoader(DataLoader):
async def batch_load_fn(self, keys):
# return await batch_get_heroes()
# SCHEMA DEFINITION
type_defs = gql("""
type Query {
heroes: [Hero!]!
}
type Hero {
name: String!
shortName: String
title: String
}
""")
# RESOLVERS
query = ResolverMap("Query")
hero = ResolverMap("Hero")
@query.field("heroes")
async def resolve_heroes(*_):
return await heroesLoader.load('_')
start_simple_server(type_defs, [query, hero])
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
async function - JavaScript - MDN Web Docs - Mozilla
The async function declaration declares an async function where the await keyword is permitted within the function body. The async and await ......
Read more >Task asynchronous programming model - Microsoft Learn
Asynchronous methods that you define by using the async keyword are referred to as async methods. The following example shows an async method....
Read more >Async/await - The Modern JavaScript Tutorial
The word “async” before a function means one simple thing: a function always returns a promise. Other values are wrapped in a resolved...
Read more >JavaScript Async - W3Schools
Example without reject. async function myDisplay() { let myPromise = new Promise(function(resolve) { resolve("I love You !!"); }); document.
Read more >Asynchronous Programming Using Async/Await in C# - SitePoint
The async keyword is added to the method signature to enable the usage of the await keyword in the method. It also instructs...
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 Free
Top 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
If you want to help, please take a look on issues marked with Help wanted.
I’ll close this issue, since it looks like it’s already on the team’s radar!