Skip to content

Commit c698f13

Browse files
gatsbybotTylerBarnespieh
authored
fix(gatsby-source-wordpress): WPGraphQL 1.13.0 compatibility (#37134) (#37183)
* fix(gatsby-source-wordpress): WPGraphQL 1.13.0 compatibility (#37134) (cherry picked from commit dd52a14) * v4 starters * v4 assertion Co-authored-by: Tyler Barnes <[email protected]> Co-authored-by: pieh <[email protected]>
1 parent 49cca44 commit c698f13

File tree

23 files changed

+430
-252
lines changed

23 files changed

+430
-252
lines changed

integration-tests/gatsby-cli/__tests__/new.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ describe(`gatsby new`, () => {
2929
})
3030

3131
it(`creates a gatsby site with the default starter`, () => {
32-
const [code, logs] = GatsbyCLI.from(cwd).invoke([`new`, `gatsby-default`])
32+
const [code, logs] = GatsbyCLI.from(cwd).invoke([
33+
`new`,
34+
`gatsby-default`,
35+
`gatsbyjs/gatsby-starter-default#v4`,
36+
])
3337

3438
logs.should.contain(
3539
`info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-default.git`
@@ -48,7 +52,7 @@ describe(`gatsby new`, () => {
4852
const [code, logs] = GatsbyCLI.from(cwd).invoke([
4953
`new`,
5054
`gatsby-blog`,
51-
`gatsbyjs/gatsby-starter-blog`,
55+
`gatsbyjs/gatsby-starter-blog#v4`,
5256
])
5357

5458
logs.should.contain(

integration-tests/gatsby-source-wordpress/__tests__/__snapshots__/index.js.snap

+53-30
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ Object {
9595
"databaseId": 564,
9696
"id": "cG9zdDo1NjQ=",
9797
"label": "Activity",
98-
"nodeType": "MenuItem",
9998
"target": null,
10099
"title": null,
101100
"url": "/activity/",
@@ -132,7 +131,6 @@ Object {
132131
"databaseId": 565,
133132
"id": "cG9zdDo1NjU=",
134133
"label": "Sample Page",
135-
"nodeType": "MenuItem",
136134
"target": null,
137135
"title": null,
138136
"url": "/sample-page/",
@@ -154,7 +152,6 @@ Object {
154152
"databaseId": 566,
155153
"id": "cG9zdDo1NjY=",
156154
"label": "Hello world!",
157-
"nodeType": "MenuItem",
158155
"target": null,
159156
"title": null,
160157
"url": "/2020/02/25/hello-world/",
@@ -166,7 +163,6 @@ Object {
166163
"databaseId": 567,
167164
"id": "cG9zdDo1Njc=",
168165
"label": "test custom link",
169-
"nodeType": "MenuItem",
170166
"target": null,
171167
"title": null,
172168
"url": "https://google.com",
@@ -218,7 +214,6 @@ Object {
218214
"databaseId": 564,
219215
"id": "cG9zdDo1NjQ=",
220216
"label": "Activity",
221-
"nodeType": "MenuItem",
222217
"target": null,
223218
"title": null,
224219
"url": "/activity/",
@@ -255,7 +250,6 @@ Object {
255250
"databaseId": 565,
256251
"id": "cG9zdDo1NjU=",
257252
"label": "Sample Page",
258-
"nodeType": "MenuItem",
259253
"target": null,
260254
"title": null,
261255
"url": "/sample-page/",
@@ -277,7 +271,6 @@ Object {
277271
"databaseId": 566,
278272
"id": "cG9zdDo1NjY=",
279273
"label": "Hello world!",
280-
"nodeType": "MenuItem",
281274
"target": null,
282275
"title": null,
283276
"url": "/2020/02/25/hello-world/",
@@ -289,7 +282,6 @@ Object {
289282
"databaseId": 567,
290283
"id": "cG9zdDo1Njc=",
291284
"label": "test custom link",
292-
"nodeType": "MenuItem",
293285
"target": null,
294286
"title": null,
295287
"url": "https://google.com",
@@ -783,7 +775,6 @@ Object {
783775
"writingSettingsDefaultPostFormat": "",
784776
"writingSettingsUseSmilies": true,
785777
},
786-
"nodeType": null,
787778
"writingSettings": Object {
788779
"defaultCategory": 23,
789780
"defaultPostFormat": "0",
@@ -960,7 +951,6 @@ Array [
960951
"seo",
961952
"viewer",
962953
"writingSettings",
963-
"nodeType",
964954
"id",
965955
"parent",
966956
"children",
@@ -1074,7 +1064,6 @@ Array [
10741064
"termGroupId",
10751065
"termTaxonomyId",
10761066
"uri",
1077-
"nodeType",
10781067
"parent",
10791068
"children",
10801069
"internal",
@@ -1212,7 +1201,6 @@ Array [
12121201
"parentId",
12131202
"replies",
12141203
"type",
1215-
"nodeType",
12161204
"parent",
12171205
"children",
12181206
"internal",
@@ -1227,7 +1215,6 @@ Array [
12271215
"id",
12281216
"name",
12291217
"url",
1230-
"nodeType",
12311218
"parent",
12321219
"children",
12331220
"internal",
@@ -1424,7 +1411,6 @@ Array [
14241411
"slug",
14251412
"status",
14261413
"uri",
1427-
"nodeType",
14281414
"parent",
14291415
"children",
14301416
"internal",
@@ -1556,7 +1542,6 @@ Array [
15561542
"showInRest",
15571543
"showUi",
15581544
"uri",
1559-
"nodeType",
15601545
"parent",
15611546
"children",
15621547
"internal",
@@ -5575,7 +5560,6 @@ Array [
55755560
"status",
55765561
"title",
55775562
"uri",
5578-
"nodeType",
55795563
"localFile",
55805564
"parent",
55815565
"children",
@@ -5704,7 +5688,6 @@ Array [
57045688
"menuItems",
57055689
"name",
57065690
"slug",
5707-
"nodeType",
57085691
"parent",
57095692
"children",
57105693
"internal",
@@ -5776,7 +5759,6 @@ Array [
57765759
"target",
57775760
"title",
57785761
"url",
5779-
"nodeType",
57805762
"parent",
57815763
"children",
57825764
"internal",
@@ -5971,9 +5953,62 @@ Array [
59715953
"status",
59725954
"template",
59735955
"uri",
5956+
"parent",
5957+
"children",
5958+
"internal",
59745959
],
59755960
"name": "WpNodeWithFeaturedImage",
59765961
},
5962+
Object {
5963+
"fields": Array [
5964+
"totalCount",
5965+
"edges",
5966+
"nodes",
5967+
"pageInfo",
5968+
"distinct",
5969+
"max",
5970+
"min",
5971+
"sum",
5972+
"group",
5973+
],
5974+
"name": "WpNodeWithFeaturedImageConnection",
5975+
},
5976+
Object {
5977+
"fields": Array [
5978+
"next",
5979+
"node",
5980+
"previous",
5981+
],
5982+
"name": "WpNodeWithFeaturedImageEdge",
5983+
},
5984+
Object {
5985+
"fields": null,
5986+
"name": "WpNodeWithFeaturedImageFieldsEnum",
5987+
},
5988+
Object {
5989+
"fields": null,
5990+
"name": "WpNodeWithFeaturedImageFilterInput",
5991+
},
5992+
Object {
5993+
"fields": Array [
5994+
"totalCount",
5995+
"edges",
5996+
"nodes",
5997+
"pageInfo",
5998+
"distinct",
5999+
"max",
6000+
"min",
6001+
"sum",
6002+
"group",
6003+
"field",
6004+
"fieldValue",
6005+
],
6006+
"name": "WpNodeWithFeaturedImageGroupConnection",
6007+
},
6008+
Object {
6009+
"fields": null,
6010+
"name": "WpNodeWithFeaturedImageSortInput",
6011+
},
59776012
Object {
59786013
"fields": Array [
59796014
"node",
@@ -6063,7 +6098,6 @@ Array [
60636098
"template",
60646099
"title",
60656100
"uri",
6066-
"nodeType",
60676101
"beforeChangeNodeTest",
60686102
"parent",
60696103
"children",
@@ -6288,7 +6322,6 @@ Array [
62886322
"title",
62896323
"toPing",
62906324
"uri",
6291-
"nodeType",
62926325
"beforeChangeNodeTest",
62936326
"parent",
62946327
"children",
@@ -6349,7 +6382,6 @@ Array [
63496382
"termGroupId",
63506383
"termTaxonomyId",
63516384
"uri",
6352-
"nodeType",
63536385
"parent",
63546386
"children",
63556387
"internal",
@@ -6620,7 +6652,6 @@ Array [
66206652
"template",
66216653
"title",
66226654
"uri",
6623-
"nodeType",
66246655
"parent",
66256656
"children",
66266657
"internal",
@@ -7090,7 +7121,6 @@ Array [
70907121
"termGroupId",
70917122
"termTaxonomyId",
70927123
"uri",
7093-
"nodeType",
70947124
"parent",
70957125
"children",
70967126
"internal",
@@ -7203,7 +7233,6 @@ Array [
72037233
"showInQuickEdit",
72047234
"showInRest",
72057235
"showUi",
7206-
"nodeType",
72077236
"parent",
72087237
"children",
72097238
"internal",
@@ -7322,7 +7351,6 @@ Array [
73227351
"termGroupId",
73237352
"termTaxonomyId",
73247353
"uri",
7325-
"nodeType",
73267354
"parent",
73277355
"children",
73287356
"internal",
@@ -7417,7 +7445,6 @@ Array [
74177445
"template",
74187446
"title",
74197447
"uri",
7420-
"nodeType",
74217448
"parent",
74227449
"children",
74237450
"internal",
@@ -7512,7 +7539,6 @@ Array [
75127539
"template",
75137540
"title",
75147541
"uri",
7515-
"nodeType",
75167542
"parent",
75177543
"children",
75187544
"internal",
@@ -7607,7 +7633,6 @@ Array [
76077633
"template",
76087634
"title",
76097635
"uri",
7610-
"nodeType",
76117636
"parent",
76127637
"children",
76137638
"internal",
@@ -7704,7 +7729,6 @@ Array [
77047729
"uri",
77057730
"url",
77067731
"username",
7707-
"nodeType",
77087732
"parent",
77097733
"children",
77107734
"internal",
@@ -7763,7 +7787,6 @@ Array [
77637787
"displayName",
77647788
"id",
77657789
"name",
7766-
"nodeType",
77677790
"parent",
77687791
"children",
77697792
"internal",

integration-tests/gatsby-source-wordpress/__tests__/index.js

+40
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,45 @@ const {
1818
resetSchema,
1919
} = require(`../test-fns/test-utils/increment-remote-data`)
2020

21+
const {
22+
default: fetchGraphql,
23+
} = require("gatsby-source-wordpress/dist/utils/fetch-graphql")
24+
2125
jest.setTimeout(100000)
2226

27+
const pluginsAreReady = async () => {
28+
let pluginsAreReady = false
29+
let tryCount = 0
30+
31+
while (!pluginsAreReady && tryCount < 20) {
32+
try {
33+
tryCount++
34+
35+
const response = await fetchGraphql({
36+
url: `http://localhost:8001/graphql`,
37+
query: /* GraphQL */ `
38+
{
39+
__type(name: "AttachFeaturedImageToNodeByIdPayload") {
40+
name
41+
}
42+
}
43+
`,
44+
})
45+
46+
if (
47+
response?.data?.__type?.name === `AttachFeaturedImageToNodeByIdPayload`
48+
) {
49+
pluginsAreReady = true
50+
}
51+
} catch (e) {
52+
console.error(e)
53+
await new Promise(resolve => setTimeout(resolve, 1000))
54+
}
55+
}
56+
57+
return pluginsAreReady
58+
}
59+
2360
// we run these tests twice in a row
2461
// to make sure everything passes on a warm cache build
2562
// we don't need to re-run some tests the second time,
@@ -34,6 +71,9 @@ describe(`[gatsby-source-wordpress] Build default options`, () => {
3471
console.log(`Waiting for WPGraphQL to be ready...`)
3572
await urling({ url: `http://localhost:8001/graphql`, retry: 100 })
3673
console.log(`WPGraphQL is ready`)
74+
console.log(`Waiting for plugins to be ready...`)
75+
await pluginsAreReady()
76+
console.log(`Plugins are ready`)
3777

3878
if (isWarmCache) {
3979
done()

integration-tests/gatsby-source-wordpress/test-fns/test-utils/queries.js

-2
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,6 @@ exports.queries = {
530530
id
531531
label
532532
databaseId
533-
nodeType
534533
target
535534
title
536535
url
@@ -670,7 +669,6 @@ exports.queries = {
670669
writingSettingsDefaultPostFormat
671670
writingSettingsUseSmilies
672671
}
673-
nodeType
674672
writingSettings {
675673
defaultCategory
676674
defaultPostFormat

0 commit comments

Comments
 (0)