gatsby 4.18.0-next.2 → 4.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cache-dir/app.js +26 -23
- package/cache-dir/commonjs/app.js +26 -24
- package/cache-dir/commonjs/ssr-develop-static-entry.js +4 -12
- package/cache-dir/commonjs/static-entry.js +3 -1
- package/cache-dir/ssr-develop-static-entry.js +13 -22
- package/cache-dir/static-entry.js +3 -1
- package/dist/datastore/in-memory/indexing.d.ts +1 -0
- package/dist/datastore/in-memory/indexing.js +30 -75
- package/dist/datastore/in-memory/indexing.js.map +1 -1
- package/dist/internal-plugins/functions/gatsby-node.js +11 -1
- package/dist/internal-plugins/functions/gatsby-node.js.map +1 -1
- package/dist/internal-plugins/partytown/gatsby-node.js +2 -2
- package/dist/internal-plugins/partytown/gatsby-node.js.map +1 -1
- package/dist/redux/persist.js +0 -1
- package/dist/redux/persist.js.map +1 -1
- package/dist/redux/reducers/inference-metadata.js +1 -1
- package/dist/redux/reducers/inference-metadata.js.map +1 -1
- package/dist/redux/reducers/resolved-nodes.js +26 -1
- package/dist/redux/reducers/resolved-nodes.js.map +1 -1
- package/dist/redux/types.d.ts +0 -1
- package/dist/redux/types.js.map +1 -1
- package/dist/schema/node-model.js +19 -41
- package/dist/schema/node-model.js.map +1 -1
- package/dist/schema/resolvers.d.ts +5 -5
- package/dist/schema/resolvers.js +156 -141
- package/dist/schema/resolvers.js.map +1 -1
- package/dist/schema/types/pagination.js +5 -5
- package/dist/schema/types/pagination.js.map +1 -1
- package/dist/schema/utils.d.ts +18 -0
- package/dist/schema/utils.js +114 -0
- package/dist/schema/utils.js.map +1 -0
- package/dist/utils/detect-node-mutations.js +2 -2
- package/dist/utils/detect-node-mutations.js.map +1 -1
- package/dist/utils/parcel/compile-gatsby-files.d.ts +1 -1
- package/dist/utils/parcel/compile-gatsby-files.js +61 -12
- package/dist/utils/parcel/compile-gatsby-files.js.map +1 -1
- package/package.json +24 -29
package/cache-dir/app.js
CHANGED
|
@@ -40,23 +40,36 @@ loader.setApiRunner(apiRunner)
|
|
|
40
40
|
|
|
41
41
|
window.___loader = publicLoader
|
|
42
42
|
|
|
43
|
-
let
|
|
44
|
-
let reactHydrate
|
|
43
|
+
let reactFirstRenderOrHydrate
|
|
45
44
|
if (HAS_REACT_18) {
|
|
46
45
|
const reactDomClient = require(`react-dom/client`)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
reactFirstRenderOrHydrate = (Component, el) => {
|
|
47
|
+
// we will use hydrate if mount element has any content inside
|
|
48
|
+
const useHydrate = el && el.children.length
|
|
49
|
+
|
|
50
|
+
if (useHydrate) {
|
|
51
|
+
const root = reactDomClient.hydrateRoot(el, Component)
|
|
52
|
+
return () => root.unmount()
|
|
53
|
+
} else {
|
|
54
|
+
const root = reactDomClient.createRoot(el)
|
|
55
|
+
root.render(Component)
|
|
56
|
+
return () => root.unmount()
|
|
57
|
+
}
|
|
51
58
|
}
|
|
52
|
-
reactHydrate = (Component, el) => reactDomClient.hydrateRoot(el, Component)
|
|
53
59
|
} else {
|
|
54
60
|
const reactDomClient = require(`react-dom`)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
61
|
+
reactFirstRenderOrHydrate = (Component, el) => {
|
|
62
|
+
// we will use hydrate if mount element has any content inside
|
|
63
|
+
const useHydrate = el && el.children.length
|
|
64
|
+
|
|
65
|
+
if (useHydrate) {
|
|
66
|
+
reactDomClient.hydrate(Component, el)
|
|
67
|
+
return () => ReactDOM.unmountComponentAtNode(el)
|
|
68
|
+
} else {
|
|
69
|
+
reactDomClient.render(Component, el)
|
|
70
|
+
return () => ReactDOM.unmountComponentAtNode(el)
|
|
71
|
+
}
|
|
58
72
|
}
|
|
59
|
-
reactHydrate = reactDomClient.hydrate
|
|
60
73
|
}
|
|
61
74
|
|
|
62
75
|
// Do dummy dynamic import so the jsonp __webpack_require__.e is added to the commons.js
|
|
@@ -147,20 +160,10 @@ apiRunnerAsync(`onClientEntry`).then(() => {
|
|
|
147
160
|
}
|
|
148
161
|
|
|
149
162
|
const rootElement = document.getElementById(`___gatsby`)
|
|
150
|
-
|
|
151
|
-
const focusEl = document.getElementById(`gatsby-focus-wrapper`)
|
|
152
|
-
|
|
153
|
-
// Client only pages have any empty body so we just do a normal
|
|
154
|
-
// render to avoid React complaining about hydration mis-matches.
|
|
155
|
-
let defaultRenderer = reactRender
|
|
156
|
-
if (focusEl && focusEl.children.length) {
|
|
157
|
-
defaultRenderer = reactHydrate
|
|
158
|
-
}
|
|
159
|
-
|
|
160
163
|
const renderer = apiRunner(
|
|
161
164
|
`replaceHydrateFunction`,
|
|
162
165
|
undefined,
|
|
163
|
-
|
|
166
|
+
reactFirstRenderOrHydrate
|
|
164
167
|
)[0]
|
|
165
168
|
|
|
166
169
|
let dismissLoadingIndicator
|
|
@@ -184,7 +187,7 @@ apiRunnerAsync(`onClientEntry`).then(() => {
|
|
|
184
187
|
if (indicatorMountElement) {
|
|
185
188
|
// If user defined replaceHydrateFunction themselves the cleanupFn return might not be there
|
|
186
189
|
// So fallback to unmountComponentAtNode for now
|
|
187
|
-
if (cleanupFn) {
|
|
190
|
+
if (cleanupFn && typeof cleanupFn === `function`) {
|
|
188
191
|
cleanupFn()
|
|
189
192
|
} else {
|
|
190
193
|
ReactDOM.unmountComponentAtNode(indicatorMountElement)
|
|
@@ -52,28 +52,39 @@ const loader = new _devLoader.default(_asyncRequires.default, _matchPaths.defaul
|
|
|
52
52
|
(0, _loader.setLoader)(loader);
|
|
53
53
|
loader.setApiRunner(_apiRunnerBrowser.apiRunner);
|
|
54
54
|
window.___loader = _loader.publicLoader;
|
|
55
|
-
let
|
|
56
|
-
let reactHydrate;
|
|
55
|
+
let reactFirstRenderOrHydrate;
|
|
57
56
|
|
|
58
57
|
if (HAS_REACT_18) {
|
|
59
58
|
const reactDomClient = require(`react-dom/client`);
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return () => root.unmount();
|
|
65
|
-
};
|
|
60
|
+
reactFirstRenderOrHydrate = (Component, el) => {
|
|
61
|
+
// we will use hydrate if mount element has any content inside
|
|
62
|
+
const useHydrate = el && el.children.length;
|
|
66
63
|
|
|
67
|
-
|
|
64
|
+
if (useHydrate) {
|
|
65
|
+
const root = reactDomClient.hydrateRoot(el, Component);
|
|
66
|
+
return () => root.unmount();
|
|
67
|
+
} else {
|
|
68
|
+
const root = reactDomClient.createRoot(el);
|
|
69
|
+
root.render(Component);
|
|
70
|
+
return () => root.unmount();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
68
73
|
} else {
|
|
69
74
|
const reactDomClient = require(`react-dom`);
|
|
70
75
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
};
|
|
76
|
+
reactFirstRenderOrHydrate = (Component, el) => {
|
|
77
|
+
// we will use hydrate if mount element has any content inside
|
|
78
|
+
const useHydrate = el && el.children.length;
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
if (useHydrate) {
|
|
81
|
+
reactDomClient.hydrate(Component, el);
|
|
82
|
+
return () => _reactDom.default.unmountComponentAtNode(el);
|
|
83
|
+
} else {
|
|
84
|
+
reactDomClient.render(Component, el);
|
|
85
|
+
return () => _reactDom.default.unmountComponentAtNode(el);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
77
88
|
} // Do dummy dynamic import so the jsonp __webpack_require__.e is added to the commons.js
|
|
78
89
|
// bundle. This ensures hot reloading doesn't break when someone first adds
|
|
79
90
|
// a dynamic import.
|
|
@@ -139,16 +150,7 @@ function notCalledFunction() {
|
|
|
139
150
|
}
|
|
140
151
|
|
|
141
152
|
const rootElement = document.getElementById(`___gatsby`);
|
|
142
|
-
const
|
|
143
|
-
// render to avoid React complaining about hydration mis-matches.
|
|
144
|
-
|
|
145
|
-
let defaultRenderer = reactRender;
|
|
146
|
-
|
|
147
|
-
if (focusEl && focusEl.children.length) {
|
|
148
|
-
defaultRenderer = reactHydrate;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
const renderer = (0, _apiRunnerBrowser.apiRunner)(`replaceHydrateFunction`, undefined, defaultRenderer)[0];
|
|
153
|
+
const renderer = (0, _apiRunnerBrowser.apiRunner)(`replaceHydrateFunction`, undefined, reactFirstRenderOrHydrate)[0];
|
|
152
154
|
let dismissLoadingIndicator;
|
|
153
155
|
|
|
154
156
|
if (process.env.GATSBY_EXPERIMENTAL_QUERY_ON_DEMAND && process.env.GATSBY_QUERY_ON_DEMAND_LOADING_INDICATOR === `true`) {
|
|
@@ -166,7 +168,7 @@ function notCalledFunction() {
|
|
|
166
168
|
if (indicatorMountElement) {
|
|
167
169
|
// If user defined replaceHydrateFunction themselves the cleanupFn return might not be there
|
|
168
170
|
// So fallback to unmountComponentAtNode for now
|
|
169
|
-
if (cleanupFn) {
|
|
171
|
+
if (cleanupFn && typeof cleanupFn === `function`) {
|
|
170
172
|
cleanupFn();
|
|
171
173
|
} else {
|
|
172
174
|
_reactDom.default.unmountComponentAtNode(indicatorMountElement);
|
|
@@ -239,15 +239,8 @@ async function staticPage({
|
|
|
239
239
|
...(((_pageData$result = pageData.result) === null || _pageData$result === void 0 ? void 0 : (_pageData$result$page = _pageData$result.pageContext) === null || _pageData$result$page === void 0 ? void 0 : _pageData$result$page.__params) || {})
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
if (_ssrSyncRequires.default.ssrComponents[componentChunkName] && !isClientOnlyPage) {
|
|
245
|
-
pageElement = /*#__PURE__*/_react.default.createElement(preferDefault(_ssrSyncRequires.default.ssrComponents[componentChunkName]), props);
|
|
246
|
-
} else {
|
|
247
|
-
// If this is a client-only page or the pageComponent didn't finish
|
|
248
|
-
// compiling yet, just render an empty component.
|
|
249
|
-
pageElement = () => null;
|
|
250
|
-
}
|
|
242
|
+
|
|
243
|
+
const pageElement = /*#__PURE__*/_react.default.createElement(preferDefault(_ssrSyncRequires.default.ssrComponents[componentChunkName]), props);
|
|
251
244
|
|
|
252
245
|
const wrappedPage = (0, _apiRunnerSsr.apiRunner)(`wrapPageElement`, {
|
|
253
246
|
element: pageElement,
|
|
@@ -265,15 +258,14 @@ async function staticPage({
|
|
|
265
258
|
|
|
266
259
|
}
|
|
267
260
|
|
|
268
|
-
const routerElement = /*#__PURE__*/_react.default.createElement(_router.ServerLocation, {
|
|
261
|
+
const routerElement = _ssrSyncRequires.default.ssrComponents[componentChunkName] && !isClientOnlyPage ? /*#__PURE__*/_react.default.createElement(_router.ServerLocation, {
|
|
269
262
|
url: `${__BASE_PATH__}${pagePath}`
|
|
270
263
|
}, /*#__PURE__*/_react.default.createElement(_router.Router, {
|
|
271
264
|
id: "gatsby-focus-wrapper",
|
|
272
265
|
baseuri: __BASE_PATH__
|
|
273
266
|
}, /*#__PURE__*/_react.default.createElement(RouteHandler, {
|
|
274
267
|
path: "/*"
|
|
275
|
-
})), /*#__PURE__*/_react.default.createElement("div", _routeAnnouncerProps.RouteAnnouncerProps));
|
|
276
|
-
|
|
268
|
+
})), /*#__PURE__*/_react.default.createElement("div", _routeAnnouncerProps.RouteAnnouncerProps)) : null;
|
|
277
269
|
const bodyComponent = (0, _apiRunnerSsr.apiRunner)(`wrapRootElement`, {
|
|
278
270
|
element: routerElement,
|
|
279
271
|
pathname: pagePath
|
|
@@ -235,20 +235,10 @@ export default async function staticPage({
|
|
|
235
235
|
},
|
|
236
236
|
}
|
|
237
237
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
) {
|
|
243
|
-
pageElement = React.createElement(
|
|
244
|
-
preferDefault(syncRequires.ssrComponents[componentChunkName]),
|
|
245
|
-
props
|
|
246
|
-
)
|
|
247
|
-
} else {
|
|
248
|
-
// If this is a client-only page or the pageComponent didn't finish
|
|
249
|
-
// compiling yet, just render an empty component.
|
|
250
|
-
pageElement = () => null
|
|
251
|
-
}
|
|
238
|
+
const pageElement = React.createElement(
|
|
239
|
+
preferDefault(syncRequires.ssrComponents[componentChunkName]),
|
|
240
|
+
props
|
|
241
|
+
)
|
|
252
242
|
|
|
253
243
|
const wrappedPage = apiRunner(
|
|
254
244
|
`wrapPageElement`,
|
|
@@ -263,14 +253,15 @@ export default async function staticPage({
|
|
|
263
253
|
}
|
|
264
254
|
}
|
|
265
255
|
|
|
266
|
-
const routerElement =
|
|
267
|
-
|
|
268
|
-
<
|
|
269
|
-
<
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
256
|
+
const routerElement =
|
|
257
|
+
syncRequires.ssrComponents[componentChunkName] && !isClientOnlyPage ? (
|
|
258
|
+
<ServerLocation url={`${__BASE_PATH__}${pagePath}`}>
|
|
259
|
+
<Router id="gatsby-focus-wrapper" baseuri={__BASE_PATH__}>
|
|
260
|
+
<RouteHandler path="/*" />
|
|
261
|
+
</Router>
|
|
262
|
+
<div {...RouteAnnouncerProps} />
|
|
263
|
+
</ServerLocation>
|
|
264
|
+
) : null
|
|
274
265
|
|
|
275
266
|
const bodyComponent = apiRunner(
|
|
276
267
|
`wrapRootElement`,
|
|
@@ -12,14 +12,14 @@ exports.unionNodesByCounter = unionNodesByCounter;
|
|
|
12
12
|
|
|
13
13
|
var _every2 = _interopRequireDefault(require("lodash/every"));
|
|
14
14
|
|
|
15
|
-
var _redux = require("../../redux");
|
|
16
|
-
|
|
17
15
|
var _query = require("../common/query");
|
|
18
16
|
|
|
19
17
|
var _2 = require("../");
|
|
20
18
|
|
|
21
19
|
var _getValueAt = require("../../utils/get-value-at");
|
|
22
20
|
|
|
21
|
+
var _utils = require("../../schema/utils");
|
|
22
|
+
|
|
23
23
|
const nodeIdToIdentifierMap = new Map();
|
|
24
24
|
/**
|
|
25
25
|
* Grabs an instance of IGatsbyNodePartial for the given node.
|
|
@@ -49,30 +49,27 @@ const getGatsbyNodePartial = (node, indexFields, resolvedFields) => {
|
|
|
49
49
|
const fieldsToStore = derefPartial ? new Set([...derefPartial.gatsbyNodePartialInternalData.indexFields, ...indexFields]) : new Set(indexFields);
|
|
50
50
|
const sortFieldIds = getSortFieldIdentifierKeys([...fieldsToStore], resolvedFields);
|
|
51
51
|
let fullNodeObject = node.gatsbyNodePartialInternalData ? undefined : node;
|
|
52
|
+
let resolvedNodeFields;
|
|
52
53
|
|
|
53
54
|
for (const dottedField of sortFieldIds) {
|
|
54
55
|
if (dottedField in node) {
|
|
55
56
|
dottedFields[dottedField] = node[dottedField];
|
|
56
57
|
} else {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (dottedField.startsWith(`__gatsby_resolved.`) && !fullNodeObject.__gatsby_resolved) {
|
|
63
|
-
const typeName = fullNodeObject.internal.type;
|
|
64
|
-
|
|
65
|
-
const resolvedNodes = _redux.store.getState().resolvedNodesCache.get(typeName);
|
|
66
|
-
|
|
67
|
-
const resolved = resolvedNodes === null || resolvedNodes === void 0 ? void 0 : resolvedNodes.get(fullNodeObject.id);
|
|
68
|
-
|
|
69
|
-
if (resolved !== undefined) {
|
|
70
|
-
fullNodeObject.__gatsby_resolved = resolved;
|
|
58
|
+
if (dottedField.startsWith(`__gatsby_resolved.`)) {
|
|
59
|
+
if (!resolvedNodeFields) {
|
|
60
|
+
resolvedNodeFields = (0, _utils.getResolvedFields)(node);
|
|
71
61
|
}
|
|
72
|
-
} // use the full node object to fetch the value
|
|
73
62
|
|
|
63
|
+
dottedFields[dottedField] = (0, _getValueAt.getValueAt)(resolvedNodeFields, dottedField.slice(`__gatsby_resolved.`.length));
|
|
64
|
+
} else {
|
|
65
|
+
// if we haven't gotten the full node object, fetch it once
|
|
66
|
+
// use the full node object to fetch the value
|
|
67
|
+
if (!fullNodeObject) {
|
|
68
|
+
fullNodeObject = (0, _2.getNode)(node.id);
|
|
69
|
+
}
|
|
74
70
|
|
|
75
|
-
|
|
71
|
+
dottedFields[dottedField] = (0, _getValueAt.getValueAt)(fullNodeObject, dottedField);
|
|
72
|
+
}
|
|
76
73
|
}
|
|
77
74
|
} // create the partial object
|
|
78
75
|
|
|
@@ -80,7 +77,8 @@ const getGatsbyNodePartial = (node, indexFields, resolvedFields) => {
|
|
|
80
77
|
const partial = Object.assign(dottedFields, {
|
|
81
78
|
id: node.id,
|
|
82
79
|
internal: {
|
|
83
|
-
counter: node.internal.counter
|
|
80
|
+
counter: node.internal.counter,
|
|
81
|
+
type: node.internal.type
|
|
84
82
|
},
|
|
85
83
|
gatsbyNodePartialInternalData: {
|
|
86
84
|
indexFields: fieldsToStore
|
|
@@ -200,9 +198,6 @@ function postIndexingMetaSetupLtLteGtGte(filterCache, op) {
|
|
|
200
198
|
|
|
201
199
|
|
|
202
200
|
const ensureIndexByQuery = (op, filterCacheKey, filterPath, nodeTypeNames, filtersCache, indexFields, resolvedFields) => {
|
|
203
|
-
const state = _redux.store.getState();
|
|
204
|
-
|
|
205
|
-
const resolvedNodesCache = state.resolvedNodesCache;
|
|
206
201
|
const filterCache = {
|
|
207
202
|
op,
|
|
208
203
|
byValue: new Map(),
|
|
@@ -218,7 +213,6 @@ const ensureIndexByQuery = (op, filterCacheKey, filterPath, nodeTypeNames, filte
|
|
|
218
213
|
node,
|
|
219
214
|
chain: filterPath,
|
|
220
215
|
filterCache,
|
|
221
|
-
resolvedNodesCache,
|
|
222
216
|
indexFields,
|
|
223
217
|
resolvedFields
|
|
224
218
|
});
|
|
@@ -235,7 +229,6 @@ const ensureIndexByQuery = (op, filterCacheKey, filterPath, nodeTypeNames, filte
|
|
|
235
229
|
node,
|
|
236
230
|
chain: filterPath,
|
|
237
231
|
filterCache,
|
|
238
|
-
resolvedNodesCache,
|
|
239
232
|
indexFields,
|
|
240
233
|
resolvedFields
|
|
241
234
|
});
|
|
@@ -251,9 +244,6 @@ function ensureEmptyFilterCache(filterCacheKey, nodeTypeNames, filtersCache, ind
|
|
|
251
244
|
// This is called for queries without any filters
|
|
252
245
|
// We want to cache the result since it's basically a list of nodes by type(s)
|
|
253
246
|
// There are sites that have multiple queries which are empty
|
|
254
|
-
const state = _redux.store.getState();
|
|
255
|
-
|
|
256
|
-
const resolvedNodesCache = state.resolvedNodesCache;
|
|
257
247
|
const orderedByCounter = [];
|
|
258
248
|
filtersCache.set(filterCacheKey, {
|
|
259
249
|
op: `$eq`,
|
|
@@ -267,16 +257,6 @@ function ensureEmptyFilterCache(filterCacheKey, nodeTypeNames, filtersCache, ind
|
|
|
267
257
|
|
|
268
258
|
if (nodeTypeNames.length === 1) {
|
|
269
259
|
(0, _2.getDataStore)().iterateNodesByType(nodeTypeNames[0]).forEach(node => {
|
|
270
|
-
if (!node.__gatsby_resolved) {
|
|
271
|
-
const typeName = node.internal.type;
|
|
272
|
-
const resolvedNodes = resolvedNodesCache.get(typeName);
|
|
273
|
-
const resolved = resolvedNodes === null || resolvedNodes === void 0 ? void 0 : resolvedNodes.get(node.id);
|
|
274
|
-
|
|
275
|
-
if (resolved !== undefined) {
|
|
276
|
-
node.__gatsby_resolved = resolved;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
260
|
orderedByCounter.push(getGatsbyNodePartial(node, indexFields, resolvedFields));
|
|
281
261
|
});
|
|
282
262
|
} else {
|
|
@@ -284,16 +264,6 @@ function ensureEmptyFilterCache(filterCacheKey, nodeTypeNames, filtersCache, ind
|
|
|
284
264
|
// This loop is expensive at scale (!)
|
|
285
265
|
(0, _2.getDataStore)().iterateNodes().forEach(node => {
|
|
286
266
|
if (nodeTypeNames.includes(node.internal.type)) {
|
|
287
|
-
if (!node.__gatsby_resolved) {
|
|
288
|
-
const typeName = node.internal.type;
|
|
289
|
-
const resolvedNodes = resolvedNodesCache.get(typeName);
|
|
290
|
-
const resolved = resolvedNodes === null || resolvedNodes === void 0 ? void 0 : resolvedNodes.get(node.id);
|
|
291
|
-
|
|
292
|
-
if (resolved !== undefined) {
|
|
293
|
-
node.__gatsby_resolved = resolved;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
267
|
orderedByCounter.push(getGatsbyNodePartial(node, indexFields, resolvedFields));
|
|
298
268
|
}
|
|
299
269
|
});
|
|
@@ -308,26 +278,23 @@ function addNodeToFilterCache({
|
|
|
308
278
|
node,
|
|
309
279
|
chain,
|
|
310
280
|
filterCache,
|
|
311
|
-
resolvedNodesCache,
|
|
312
281
|
indexFields,
|
|
313
282
|
resolvedFields,
|
|
314
283
|
valueOffset = node
|
|
315
284
|
}) {
|
|
316
|
-
//
|
|
317
|
-
if (!node.__gatsby_resolved) {
|
|
318
|
-
const typeName = node.internal.type;
|
|
319
|
-
const resolvedNodes = resolvedNodesCache.get(typeName);
|
|
320
|
-
node.__gatsby_resolved = resolvedNodes === null || resolvedNodes === void 0 ? void 0 : resolvedNodes.get(node.id);
|
|
321
|
-
} // - for plain query, valueOffset === node
|
|
285
|
+
// - for plain query, valueOffset === node
|
|
322
286
|
// - for elemMatch, valueOffset is sub-tree of the node to continue matching
|
|
323
|
-
|
|
324
|
-
|
|
325
287
|
let v = valueOffset;
|
|
326
288
|
let i = 0;
|
|
327
289
|
|
|
328
290
|
while (i < chain.length && v) {
|
|
329
291
|
const nextProp = chain[i++];
|
|
330
|
-
|
|
292
|
+
|
|
293
|
+
if (i === 1 && nextProp === `__gatsby_resolved`) {
|
|
294
|
+
v = (0, _utils.getResolvedFields)(v);
|
|
295
|
+
} else {
|
|
296
|
+
v = v[nextProp];
|
|
297
|
+
}
|
|
331
298
|
}
|
|
332
299
|
|
|
333
300
|
if (typeof v !== `string` && typeof v !== `number` && typeof v !== `boolean` && v !== null || i !== chain.length) {
|
|
@@ -367,11 +334,6 @@ function markNodeForValue(filterCache, node, value, indexFields, resolvedFields)
|
|
|
367
334
|
const ensureIndexByElemMatch = (op, filterCacheKey, filter, nodeTypeNames, filtersCache, indexFields, resolvedFields) => {
|
|
368
335
|
// Given an elemMatch filter, generate the cache that contains all nodes that
|
|
369
336
|
// matches a given value for that sub-query
|
|
370
|
-
const state = _redux.store.getState();
|
|
371
|
-
|
|
372
|
-
const {
|
|
373
|
-
resolvedNodesCache
|
|
374
|
-
} = state;
|
|
375
337
|
const filterCache = {
|
|
376
338
|
op,
|
|
377
339
|
byValue: new Map(),
|
|
@@ -386,7 +348,6 @@ const ensureIndexByElemMatch = (op, filterCacheKey, filter, nodeTypeNames, filte
|
|
|
386
348
|
valueAtCurrentStep: node,
|
|
387
349
|
filter,
|
|
388
350
|
filterCache,
|
|
389
|
-
resolvedNodesCache,
|
|
390
351
|
indexFields,
|
|
391
352
|
resolvedFields
|
|
392
353
|
});
|
|
@@ -403,7 +364,6 @@ const ensureIndexByElemMatch = (op, filterCacheKey, filter, nodeTypeNames, filte
|
|
|
403
364
|
valueAtCurrentStep: node,
|
|
404
365
|
filter,
|
|
405
366
|
filterCache,
|
|
406
|
-
resolvedNodesCache,
|
|
407
367
|
indexFields,
|
|
408
368
|
resolvedFields
|
|
409
369
|
});
|
|
@@ -421,17 +381,9 @@ function addNodeToBucketWithElemMatch({
|
|
|
421
381
|
// Arbitrary step on the path inside the node
|
|
422
382
|
filter,
|
|
423
383
|
filterCache,
|
|
424
|
-
resolvedNodesCache,
|
|
425
384
|
indexFields,
|
|
426
385
|
resolvedFields
|
|
427
386
|
}) {
|
|
428
|
-
// There can be a filter that targets `__gatsby_resolved` so fix that first
|
|
429
|
-
if (!node.__gatsby_resolved) {
|
|
430
|
-
const typeName = node.internal.type;
|
|
431
|
-
const resolvedNodes = resolvedNodesCache.get(typeName);
|
|
432
|
-
node.__gatsby_resolved = resolvedNodes === null || resolvedNodes === void 0 ? void 0 : resolvedNodes.get(node.id);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
387
|
const {
|
|
436
388
|
path,
|
|
437
389
|
nestedQuery
|
|
@@ -441,7 +393,12 @@ function addNodeToBucketWithElemMatch({
|
|
|
441
393
|
|
|
442
394
|
while (i < path.length && valueAtCurrentStep) {
|
|
443
395
|
const nextProp = path[i++];
|
|
444
|
-
|
|
396
|
+
|
|
397
|
+
if (i === 1 && nextProp === `__gatsby_resolved`) {
|
|
398
|
+
valueAtCurrentStep = (0, _utils.getResolvedFields)(valueAtCurrentStep);
|
|
399
|
+
} else {
|
|
400
|
+
valueAtCurrentStep = valueAtCurrentStep[nextProp];
|
|
401
|
+
}
|
|
445
402
|
}
|
|
446
403
|
|
|
447
404
|
if (path.length !== i) {
|
|
@@ -466,7 +423,6 @@ function addNodeToBucketWithElemMatch({
|
|
|
466
423
|
valueAtCurrentStep: elem,
|
|
467
424
|
filter: nestedQuery,
|
|
468
425
|
filterCache,
|
|
469
|
-
resolvedNodesCache,
|
|
470
426
|
indexFields,
|
|
471
427
|
resolvedFields
|
|
472
428
|
});
|
|
@@ -476,7 +432,6 @@ function addNodeToBucketWithElemMatch({
|
|
|
476
432
|
node,
|
|
477
433
|
chain: nestedQuery.path,
|
|
478
434
|
filterCache,
|
|
479
|
-
resolvedNodesCache,
|
|
480
435
|
indexFields,
|
|
481
436
|
resolvedFields,
|
|
482
437
|
valueOffset: elem
|