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

Commit

Permalink
make async
Browse files Browse the repository at this point in the history
  • Loading branch information
sw-yx committed Apr 10, 2019
1 parent a6cf94f commit 72d80aa
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/functions-templates/js/fauna-graphql/fauna-graphql.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {
makeRemoteExecutableSchema
} = require("graphql-tools");

exports.handler = function(event, context, cb) {
exports.handler = async function(event, context) {
/** required for Fauna GraphQL auth */
if (!process.env.FAUNADB_SERVER_SECRET) {
const msg = `
Expand All @@ -30,14 +30,16 @@ exports.handler = function(event, context, cb) {
fetch,
headers
});
introspectSchema(link).then(schema => {
const executableSchema = makeRemoteExecutableSchema({
schema,
link
});
const server = new ApolloServer({
schema: executableSchema
});
const schema = await introspectSchema(link);
const executableSchema = makeRemoteExecutableSchema({
schema,
link
});
const server = new ApolloServer({
schema: executableSchema
});
return new Promise((yay, nay) => {
const cb = (err, args) => (err ? nay(err) : yay(args));
server.createHandler()(event, context, cb);
});
};

0 comments on commit 72d80aa

Please sign in to comment.