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
  • Loading branch information
TylerBarnes committed Dec 2, 2022
1 parent 1c84345 commit dd52a14
Show file tree
Hide file tree
Showing 22 changed files with 424 additions and 250 deletions.
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 @@ -1106,7 +1096,6 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1292,7 +1281,6 @@ Array [
"parentId",
"replies",
"type",
"nodeType",
"parent",
"children",
"internal",
Expand All @@ -1307,7 +1295,6 @@ Array [
"id",
"name",
"url",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1544,7 +1531,6 @@ Array [
"slug",
"status",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1700,7 +1686,6 @@ Array [
"showInRest",
"showUi",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5783,7 +5768,6 @@ Array [
"status",
"title",
"uri",
"nodeType",
"localFile",
"parent",
"children",
Expand Down Expand Up @@ -5936,7 +5920,6 @@ Array [
"menuItems",
"name",
"slug",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6008,7 +5991,6 @@ Array [
"target",
"title",
"url",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6259,9 +6241,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": "WpNodeWithFeaturedImageFieldSelector",
},
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 @@ -6359,7 +6394,6 @@ Array [
"template",
"title",
"uri",
"nodeType",
"beforeChangeNodeTest",
"parent",
"children",
Expand Down Expand Up @@ -6616,7 +6650,6 @@ Array [
"title",
"toPing",
"uri",
"nodeType",
"beforeChangeNodeTest",
"parent",
"children",
Expand Down Expand Up @@ -6677,7 +6710,6 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7036,7 +7068,6 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7722,7 +7753,6 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7859,7 +7889,6 @@ Array [
"showInQuickEdit",
"showInRest",
"showUi",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7994,7 +8023,6 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8089,7 +8117,6 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8184,7 +8211,6 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8279,7 +8305,6 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8376,7 +8401,6 @@ Array [
"uri",
"url",
"username",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8435,7 +8459,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
4 changes: 2 additions & 2 deletions packages/gatsby-source-wordpress/src/models/remoteSchema.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { findTypeName } from "~/steps/create-schema-customization/helpers"
import { findNamedTypeName } from "~/steps/create-schema-customization/helpers"

interface IRemoteSchemaState {
wpUrl: string
Expand Down Expand Up @@ -130,7 +130,7 @@ const remoteSchema: IRemoteSchemaStore = {
},

addFetchedType(state, type) {
const key = findTypeName(type)
const key = findNamedTypeName(type)

if (!key) {
return state
Expand Down
Loading

0 comments on commit dd52a14

Please sign in to comment.