Skip to content

Commit 7021834

Browse files
gatsbybotpieh
andauthored
fix(gatsby-source-contentful): maintain back reference map between runs (#37442) (#37456)
* test(gatsby-source-contentful): add test case * fix(gatsby-source-contentful): maintain back reference map between runs (cherry picked from commit 76f979c) Co-authored-by: Michal Piechowiak <misiek.piechowiak@gmail.com>
1 parent 13bf518 commit 7021834

File tree

5 files changed

+491
-27
lines changed

5 files changed

+491
-27
lines changed
Lines changed: 339 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,339 @@
1+
exports.contentTypeItems = () => [
2+
{
3+
sys: {
4+
space: {
5+
sys: {
6+
type: `Link`,
7+
linkType: `Space`,
8+
id: `8itggr1zebzx`,
9+
},
10+
},
11+
id: `blogPost`,
12+
type: `ContentType`,
13+
createdAt: `2023-01-11T14:52:56.250Z`,
14+
updatedAt: `2023-01-11T14:54:56.940Z`,
15+
environment: {
16+
sys: {
17+
id: `master`,
18+
type: `Link`,
19+
linkType: `Environment`,
20+
},
21+
},
22+
revision: 4,
23+
},
24+
displayField: `title`,
25+
name: `Blog Post`,
26+
description: ``,
27+
fields: [
28+
{
29+
id: `title`,
30+
name: `Title`,
31+
type: `Symbol`,
32+
localized: false,
33+
required: true,
34+
disabled: false,
35+
omitted: false,
36+
},
37+
{
38+
id: `slug`,
39+
name: `Slug`,
40+
type: `Symbol`,
41+
localized: false,
42+
required: true,
43+
disabled: false,
44+
omitted: false,
45+
},
46+
{
47+
id: `body`,
48+
name: `Body`,
49+
type: `Text`,
50+
localized: false,
51+
required: true,
52+
disabled: false,
53+
omitted: false,
54+
},
55+
{
56+
id: `category`,
57+
name: `Category`,
58+
type: `Link`,
59+
localized: false,
60+
required: false,
61+
disabled: false,
62+
omitted: false,
63+
linkType: `Entry`,
64+
validations: [
65+
{
66+
linkContentType: [`blogCategory`],
67+
},
68+
],
69+
},
70+
],
71+
},
72+
{
73+
sys: {
74+
space: {
75+
sys: {
76+
type: `Link`,
77+
linkType: `Space`,
78+
id: `8itggr1zebzx`,
79+
},
80+
},
81+
id: `blogCategory`,
82+
type: `ContentType`,
83+
createdAt: `2023-01-11T14:54:22.680Z`,
84+
updatedAt: `2023-01-11T14:54:22.680Z`,
85+
environment: {
86+
sys: {
87+
id: `master`,
88+
type: `Link`,
89+
linkType: `Environment`,
90+
},
91+
},
92+
revision: 1,
93+
},
94+
displayField: `title`,
95+
name: `Blog Category`,
96+
description: ``,
97+
fields: [
98+
{
99+
id: `title`,
100+
name: `Title`,
101+
type: `Symbol`,
102+
localized: false,
103+
required: true,
104+
disabled: false,
105+
omitted: false,
106+
},
107+
{
108+
id: `slug`,
109+
name: `Slug`,
110+
type: `Symbol`,
111+
localized: false,
112+
required: true,
113+
disabled: false,
114+
omitted: false,
115+
},
116+
],
117+
},
118+
]
119+
120+
exports.initialSync = () => {
121+
return {
122+
currentSyncData: {
123+
entries: [
124+
{
125+
metadata: {
126+
tags: [],
127+
},
128+
sys: {
129+
space: {
130+
sys: {
131+
type: `Link`,
132+
linkType: `Space`,
133+
id: `8itggr1zebzx`,
134+
},
135+
},
136+
id: `3jXBlUgXmubzPI3I6d9hLr`,
137+
type: `Entry`,
138+
createdAt: `2023-01-11T14:56:37.418Z`,
139+
updatedAt: `2023-01-11T15:04:37.640Z`,
140+
environment: {
141+
sys: {
142+
id: `master`,
143+
type: `Link`,
144+
linkType: `Environment`,
145+
},
146+
},
147+
revision: 3,
148+
contentType: {
149+
sys: {
150+
type: `Link`,
151+
linkType: `ContentType`,
152+
id: `blogCategory`,
153+
},
154+
},
155+
},
156+
fields: {
157+
title: {
158+
"en-US": `CMS`,
159+
},
160+
slug: {
161+
"en-US": `cms`,
162+
},
163+
},
164+
},
165+
{
166+
metadata: {
167+
tags: [],
168+
},
169+
sys: {
170+
space: {
171+
sys: {
172+
type: `Link`,
173+
linkType: `Space`,
174+
id: `8itggr1zebzx`,
175+
},
176+
},
177+
id: `3oTFYoNKoVZcp8svbn8P2z`,
178+
type: `Entry`,
179+
createdAt: `2023-01-11T14:56:42.655Z`,
180+
updatedAt: `2023-01-11T14:56:42.655Z`,
181+
environment: {
182+
sys: {
183+
id: `master`,
184+
type: `Link`,
185+
linkType: `Environment`,
186+
},
187+
},
188+
revision: 1,
189+
contentType: {
190+
sys: {
191+
type: `Link`,
192+
linkType: `ContentType`,
193+
id: `blogPost`,
194+
},
195+
},
196+
},
197+
fields: {
198+
title: {
199+
"en-US": `Hello World`,
200+
},
201+
slug: {
202+
"en-US": `hello-world`,
203+
},
204+
body: {
205+
"en-US": `Lorem ipsum`,
206+
},
207+
category: {
208+
"en-US": {
209+
sys: {
210+
type: `Link`,
211+
linkType: `Entry`,
212+
id: `3jXBlUgXmubzPI3I6d9hLr`,
213+
},
214+
},
215+
},
216+
},
217+
},
218+
],
219+
assets: [],
220+
deletedEntries: [],
221+
deletedAssets: [],
222+
nextSyncToken: `dDFSNcK6bMO7woHDuMK7A8O_KWQDPkhAwpF6w7ovw49fQjrDj2gKH0xvwofCkMKDJcKgBMKCYcK9wr3DoVozwqEUC8OwWlVJBBt-F8K0BMKTP8OAwr8Xw6bCkcO2w6MpwqBmVX7CmsOwM3DDvWZvw5Q`,
223+
},
224+
tagItems: [],
225+
defaultLocale: `en-US`,
226+
locales: [
227+
{
228+
code: `en-US`,
229+
name: `English (United States)`,
230+
default: true,
231+
fallbackCode: null,
232+
sys: {
233+
id: `2jpGtQkqT01zpSIqC9UQOS`,
234+
type: `Locale`,
235+
version: 1,
236+
},
237+
},
238+
],
239+
space: {
240+
sys: {
241+
type: `Space`,
242+
id: `8itggr1zebzx`,
243+
},
244+
name: `test`,
245+
locales: [
246+
{
247+
code: `en-US`,
248+
default: true,
249+
name: `English (United States)`,
250+
fallbackCode: null,
251+
},
252+
],
253+
},
254+
}
255+
}
256+
257+
exports.editJustEntryWithBackLinks = () => {
258+
return {
259+
currentSyncData: {
260+
entries: [
261+
{
262+
metadata: {
263+
tags: [],
264+
},
265+
sys: {
266+
space: {
267+
sys: {
268+
type: `Link`,
269+
linkType: `Space`,
270+
id: `8itggr1zebzx`,
271+
},
272+
},
273+
id: `3jXBlUgXmubzPI3I6d9hLr`,
274+
type: `Entry`,
275+
createdAt: `2023-01-11T14:56:37.418Z`,
276+
updatedAt: `2023-01-11T15:06:18.306Z`,
277+
environment: {
278+
sys: {
279+
id: `master`,
280+
type: `Link`,
281+
linkType: `Environment`,
282+
},
283+
},
284+
revision: 4,
285+
contentType: {
286+
sys: {
287+
type: `Link`,
288+
linkType: `ContentType`,
289+
id: `blogCategory`,
290+
},
291+
},
292+
},
293+
fields: {
294+
title: {
295+
"en-US": `CMS edit #1`,
296+
},
297+
slug: {
298+
"en-US": `cms`,
299+
},
300+
},
301+
},
302+
],
303+
assets: [],
304+
deletedEntries: [],
305+
deletedAssets: [],
306+
nextSyncToken: `dDFSNcK6bMO7woHDuMK7A8O_KWQDPkhAwpF6w7ovw49fQjrDj2gKH0xvQMODwpLDkMK3Oj9Jw6jDkSoBMkc4woTCtMOFwoTDisKlT8O1w4AaKsOjasK1wrVSwrU3YsKVE8KPVMKyw4_CmVpwPsOew4IVwoA`,
307+
},
308+
tagItems: [],
309+
defaultLocale: `en-US`,
310+
locales: [
311+
{
312+
code: `en-US`,
313+
name: `English (United States)`,
314+
default: true,
315+
fallbackCode: null,
316+
sys: {
317+
id: `2jpGtQkqT01zpSIqC9UQOS`,
318+
type: `Locale`,
319+
version: 1,
320+
},
321+
},
322+
],
323+
space: {
324+
sys: {
325+
type: `Space`,
326+
id: `8itggr1zebzx`,
327+
},
328+
name: `test`,
329+
locales: [
330+
{
331+
code: `en-US`,
332+
default: true,
333+
name: `English (United States)`,
334+
fallbackCode: null,
335+
},
336+
],
337+
},
338+
}
339+
}

0 commit comments

Comments
 (0)