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

Commit 301bfc9

Browse files
author
sw-yx
committed
fix sync schema of fauna-graphql
1 parent 969b3d7 commit 301bfc9

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

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

+12-6
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,25 @@ function createFaunaGraphQL() {
1414
.readFileSync(path.join(__dirname, "schema.graphql"))
1515
.toString(); // name of your schema file
1616

17+
// encoded authorization header similar to https://www.npmjs.com/package/request#http-authentication
18+
const Authorization = Buffer.from(
19+
process.env.FAUNADB_SERVER_SECRET + ":"
20+
).toString("base64");
21+
1722
var options = {
1823
method: "POST",
1924
body: dataString,
20-
auth: {
21-
user: process.env.FAUNADB_SERVER_SECRET,
22-
pass: ""
23-
}
25+
headers: { Authorization }
2426
};
2527

2628
fetch("https://graphql.fauna.com/import", options)
29+
// // uncomment for debugging
30+
.then(res => res.text())
2731
.then(body => {
28-
// // uncomment for debugging
29-
// console.log("body", body);
32+
console.log(
33+
"Netlify Functions:Create - `fauna-graphql/sync-schema.js` success!"
34+
);
35+
console.log(body);
3036
})
3137
.catch(err => console.error("something wrong happened: ", { err }));
3238
}

0 commit comments

Comments
 (0)