Skip to content

Commit 675d0e6

Browse files
committed
fixing issue brandonmp#42.
The "boundActionCreators" API is deprecated and replaced with "action" as mentioned here: gatsbyjs/gatsby#6825. To avoid "breaking changes" for those still using GatsbyJS v1, I have not removed the boundActionCreators in the parameter list. It's up to you to make the final decision.
1 parent 4fe2d88 commit 675d0e6

File tree

2 files changed

+65
-24
lines changed

2 files changed

+65
-24
lines changed

gatsby-node.js

Lines changed: 63 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,66 @@
11
"use strict";
22

3-
const fetchSheet = require(`./fetch-sheet.js`).default;
4-
const uuidv5 = require("uuid/v5");
5-
const _ = require("lodash");
6-
const crypto = require("crypto");
7-
const seedConstant = "2972963f-2fcf-4567-9237-c09a2b436541";
8-
9-
exports.sourceNodes = async ({ boundActionCreators, getNode, store, cache }, { spreadsheetId, worksheetTitle, credentials }) => {
10-
const { createNode } = boundActionCreators;
11-
console.log("FETCHING SHEET", fetchSheet);
12-
let rows = await fetchSheet(spreadsheetId, worksheetTitle, credentials);
13-
14-
rows.forEach(r => {
15-
createNode(Object.assign(r, {
16-
id: uuidv5(r.id, uuidv5("gsheet", seedConstant)),
17-
parent: "__SOURCE__",
18-
children: [],
19-
internal: {
20-
type: _.camelCase(`googleSheet ${worksheetTitle} row`),
21-
contentDigest: crypto.createHash("md5").update(JSON.stringify(r)).digest("hex")
3+
var _regenerator = require("babel-runtime/regenerator");
4+
5+
var _regenerator2 = _interopRequireDefault(_regenerator);
6+
7+
var _asyncToGenerator2 = require("babel-runtime/helpers/asyncToGenerator");
8+
9+
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
10+
11+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12+
13+
var fetchSheet = require(`./fetch-sheet.js`).default;
14+
var uuidv5 = require("uuid/v5");
15+
var _ = require("lodash");
16+
var crypto = require("crypto");
17+
var seedConstant = "2972963f-2fcf-4567-9237-c09a2b436541";
18+
19+
exports.sourceNodes = function () {
20+
var _ref3 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(_ref, _ref2) {
21+
var boundActionCreators = _ref.boundActionCreators,
22+
getNode = _ref.getNode,
23+
store = _ref.store,
24+
cache = _ref.cache;
25+
var spreadsheetId = _ref2.spreadsheetId,
26+
worksheetTitle = _ref2.worksheetTitle,
27+
credentials = _ref2.credentials;
28+
var createNode, rows;
29+
return _regenerator2.default.wrap(function _callee$(_context) {
30+
while (1) {
31+
switch (_context.prev = _context.next) {
32+
case 0:
33+
createNode = boundActionCreators.createNode;
34+
35+
console.log("FETCHING SHEET", fetchSheet);
36+
_context.next = 4;
37+
return fetchSheet(spreadsheetId, worksheetTitle, credentials);
38+
39+
case 4:
40+
rows = _context.sent;
41+
42+
43+
rows.forEach(function (r) {
44+
createNode(Object.assign(r, {
45+
id: uuidv5(r.id, uuidv5("gsheet", seedConstant)),
46+
parent: "__SOURCE__",
47+
children: [],
48+
internal: {
49+
type: _.camelCase(`googleSheet ${worksheetTitle} row`),
50+
contentDigest: crypto.createHash("md5").update(JSON.stringify(r)).digest("hex")
51+
}
52+
}));
53+
});
54+
55+
case 6:
56+
case "end":
57+
return _context.stop();
58+
}
2259
}
23-
}));
24-
});
25-
};
60+
}, _callee, undefined);
61+
}));
62+
63+
return function (_x, _x2) {
64+
return _ref3.apply(this, arguments);
65+
};
66+
}();

src/gatsby-node.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ const crypto = require("crypto");
55
const seedConstant = "2972963f-2fcf-4567-9237-c09a2b436541";
66

77
exports.sourceNodes = async (
8-
{ boundActionCreators, getNode, store, cache },
8+
{ boundActionCreators, actions, getNode, store, cache },
99
{ spreadsheetId, worksheetTitle, credentials }
1010
) => {
11-
const { createNode } = boundActionCreators;
11+
const { createNode } = boundActionCreators || actions;
1212
console.log("FETCHING SHEET", fetchSheet);
1313
let rows = await fetchSheet(spreadsheetId, worksheetTitle, credentials);
1414

0 commit comments

Comments
 (0)