I made API server with graphql-yoga. (a nodejs library)
Before searching Google, I just use query/mutation like this.
Query: {
movies: () => { return Movies.all();}
}
But after searching I found some code that use await/async on query/mutation.
Query: {
movies: async () => { return await Movies.all(); }
}
By my little knowledge, second case is more safe and better case.
But I'm new at graphql and es6.
Is there any process related async/await already defined in graphql?
Or, do not have to consider about it?
Or, use async/await is better?
Any suggestions would be appreciated :)
Thanks.
async/await
is an ES6 paradigm unrelated to GraphQL.
You should keep working with promises until you understand it enough to feel the need for and async/await
migration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With