Skip to content

Commit

Permalink
fix(gatsby-source-wordpress): WPGraphQL 1.13.0 compatibility (#37134) (
Browse files Browse the repository at this point in the history
…#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 <tylerdbarnes@gmail.com>
Co-authored-by: pieh <misiek.piechowiak@gmail.com>
  • Loading branch information
3 people authored Dec 6, 2022
1 parent 49cca44 commit c698f13
Show file tree
Hide file tree
Showing 23 changed files with 430 additions and 252 deletions.
8 changes: 6 additions & 2 deletions integration-tests/gatsby-cli/__tests__/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ describe(`gatsby new`, () => {
})

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

logs.should.contain(
`info Creating new site from git: https://github.com/gatsbyjs/gatsby-starter-default.git`
Expand All @@ -48,7 +52,7 @@ describe(`gatsby new`, () => {
const [code, logs] = GatsbyCLI.from(cwd).invoke([
`new`,
`gatsby-blog`,
`gatsbyjs/gatsby-starter-blog`,
`gatsbyjs/gatsby-starter-blog#v4`,
])

logs.should.contain(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ Object {
"databaseId": 564,
"id": "cG9zdDo1NjQ=",
"label": "Activity",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "/activity/",
Expand Down Expand Up @@ -132,7 +131,6 @@ Object {
"databaseId": 565,
"id": "cG9zdDo1NjU=",
"label": "Sample Page",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "/sample-page/",
Expand All @@ -154,7 +152,6 @@ Object {
"databaseId": 566,
"id": "cG9zdDo1NjY=",
"label": "Hello world!",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "/2020/02/25/hello-world/",
Expand All @@ -166,7 +163,6 @@ Object {
"databaseId": 567,
"id": "cG9zdDo1Njc=",
"label": "test custom link",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "https://google.com",
Expand Down Expand Up @@ -218,7 +214,6 @@ Object {
"databaseId": 564,
"id": "cG9zdDo1NjQ=",
"label": "Activity",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "/activity/",
Expand Down Expand Up @@ -255,7 +250,6 @@ Object {
"databaseId": 565,
"id": "cG9zdDo1NjU=",
"label": "Sample Page",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "/sample-page/",
Expand All @@ -277,7 +271,6 @@ Object {
"databaseId": 566,
"id": "cG9zdDo1NjY=",
"label": "Hello world!",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "/2020/02/25/hello-world/",
Expand All @@ -289,7 +282,6 @@ Object {
"databaseId": 567,
"id": "cG9zdDo1Njc=",
"label": "test custom link",
"nodeType": "MenuItem",
"target": null,
"title": null,
"url": "https://google.com",
Expand Down Expand Up @@ -783,7 +775,6 @@ Object {
"writingSettingsDefaultPostFormat": "",
"writingSettingsUseSmilies": true,
},
"nodeType": null,
"writingSettings": Object {
"defaultCategory": 23,
"defaultPostFormat": "0",
Expand Down Expand Up @@ -960,7 +951,6 @@ Array [
"seo",
"viewer",
"writingSettings",
"nodeType",
"id",
"parent",
"children",
Expand Down Expand Up @@ -1074,7 +1064,6 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1212,7 +1201,6 @@ Array [
"parentId",
"replies",
"type",
"nodeType",
"parent",
"children",
"internal",
Expand All @@ -1227,7 +1215,6 @@ Array [
"id",
"name",
"url",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1424,7 +1411,6 @@ Array [
"slug",
"status",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1556,7 +1542,6 @@ Array [
"showInRest",
"showUi",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5575,7 +5560,6 @@ Array [
"status",
"title",
"uri",
"nodeType",
"localFile",
"parent",
"children",
Expand Down Expand Up @@ -5704,7 +5688,6 @@ Array [
"menuItems",
"name",
"slug",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5776,7 +5759,6 @@ Array [
"target",
"title",
"url",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5971,9 +5953,62 @@ Array [
"status",
"template",
"uri",
"parent",
"children",
"internal",
],
"name": "WpNodeWithFeaturedImage",
},
Object {
"fields": Array [
"totalCount",
"edges",
"nodes",
"pageInfo",
"distinct",
"max",
"min",
"sum",
"group",
],
"name": "WpNodeWithFeaturedImageConnection",
},
Object {
"fields": Array [
"next",
"node",
"previous",
],
"name": "WpNodeWithFeaturedImageEdge",
},
Object {
"fields": null,
"name": "WpNodeWithFeaturedImageFieldsEnum",
},
Object {
"fields": null,
"name": "WpNodeWithFeaturedImageFilterInput",
},
Object {
"fields": Array [
"totalCount",
"edges",
"nodes",
"pageInfo",
"distinct",
"max",
"min",
"sum",
"group",
"field",
"fieldValue",
],
"name": "WpNodeWithFeaturedImageGroupConnection",
},
Object {
"fields": null,
"name": "WpNodeWithFeaturedImageSortInput",
},
Object {
"fields": Array [
"node",
Expand Down Expand Up @@ -6063,7 +6098,6 @@ Array [
"template",
"title",
"uri",
"nodeType",
"beforeChangeNodeTest",
"parent",
"children",
Expand Down Expand Up @@ -6288,7 +6322,6 @@ Array [
"title",
"toPing",
"uri",
"nodeType",
"beforeChangeNodeTest",
"parent",
"children",
Expand Down Expand Up @@ -6349,7 +6382,6 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6620,7 +6652,6 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7090,7 +7121,6 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7203,7 +7233,6 @@ Array [
"showInQuickEdit",
"showInRest",
"showUi",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7322,7 +7351,6 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7417,7 +7445,6 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7512,7 +7539,6 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7607,7 +7633,6 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7704,7 +7729,6 @@ Array [
"uri",
"url",
"username",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7763,7 +7787,6 @@ Array [
"displayName",
"id",
"name",
"nodeType",
"parent",
"children",
"internal",
Expand Down
40 changes: 40 additions & 0 deletions integration-tests/gatsby-source-wordpress/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,45 @@ const {
resetSchema,
} = require(`../test-fns/test-utils/increment-remote-data`)

const {
default: fetchGraphql,
} = require("gatsby-source-wordpress/dist/utils/fetch-graphql")

jest.setTimeout(100000)

const pluginsAreReady = async () => {
let pluginsAreReady = false
let tryCount = 0

while (!pluginsAreReady && tryCount < 20) {
try {
tryCount++

const response = await fetchGraphql({
url: `http://localhost:8001/graphql`,
query: /* GraphQL */ `
{
__type(name: "AttachFeaturedImageToNodeByIdPayload") {
name
}
}
`,
})

if (
response?.data?.__type?.name === `AttachFeaturedImageToNodeByIdPayload`
) {
pluginsAreReady = true
}
} catch (e) {
console.error(e)
await new Promise(resolve => setTimeout(resolve, 1000))
}
}

return pluginsAreReady
}

// we run these tests twice in a row
// to make sure everything passes on a warm cache build
// we don't need to re-run some tests the second time,
Expand All @@ -34,6 +71,9 @@ describe(`[gatsby-source-wordpress] Build default options`, () => {
console.log(`Waiting for WPGraphQL to be ready...`)
await urling({ url: `http://localhost:8001/graphql`, retry: 100 })
console.log(`WPGraphQL is ready`)
console.log(`Waiting for plugins to be ready...`)
await pluginsAreReady()
console.log(`Plugins are ready`)

if (isWarmCache) {
done()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ exports.queries = {
id
label
databaseId
nodeType
target
title
url
Expand Down Expand Up @@ -670,7 +669,6 @@ exports.queries = {
writingSettingsDefaultPostFormat
writingSettingsUseSmilies
}
nodeType
writingSettings {
defaultCategory
defaultPostFormat
Expand Down
Loading

0 comments on commit c698f13

Please sign in to comment.