Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit 72d80aa

Browse files
author
sw-yx
committed
make async
1 parent a6cf94f commit 72d80aa

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/functions-templates/js/fauna-graphql/fauna-graphql.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const {
66
makeRemoteExecutableSchema
77
} = require("graphql-tools");
88

9-
exports.handler = function(event, context, cb) {
9+
exports.handler = async function(event, context) {
1010
/** required for Fauna GraphQL auth */
1111
if (!process.env.FAUNADB_SERVER_SECRET) {
1212
const msg = `
@@ -30,14 +30,16 @@ exports.handler = function(event, context, cb) {
3030
fetch,
3131
headers
3232
});
33-
introspectSchema(link).then(schema => {
34-
const executableSchema = makeRemoteExecutableSchema({
35-
schema,
36-
link
37-
});
38-
const server = new ApolloServer({
39-
schema: executableSchema
40-
});
33+
const schema = await introspectSchema(link);
34+
const executableSchema = makeRemoteExecutableSchema({
35+
schema,
36+
link
37+
});
38+
const server = new ApolloServer({
39+
schema: executableSchema
40+
});
41+
return new Promise((yay, nay) => {
42+
const cb = (err, args) => (err ? nay(err) : yay(args));
4143
server.createHandler()(event, context, cb);
4244
});
4345
};

0 commit comments

Comments
 (0)