Skip to content

Commit b7d7b07

Browse files
authored
fix(gatsby-source-wordpress): Add back nodeType field that was removed in last version (#37212)
* canary commit * move typedef interfaces definition to __all type filter * add the nodeType field to any type that implements Node * Revert "canary commit" This reverts commit fd7f83d. * update snapshot
1 parent e627fe1 commit b7d7b07

File tree

3 files changed

+49
-10
lines changed

3 files changed

+49
-10
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ Array [
951951
"seo",
952952
"viewer",
953953
"writingSettings",
954+
"nodeType",
954955
"id",
955956
"parent",
956957
"children",
@@ -1114,6 +1115,7 @@ Array [
11141115
"termGroupId",
11151116
"termTaxonomyId",
11161117
"uri",
1118+
"nodeType",
11171119
"parent",
11181120
"children",
11191121
"internal",
@@ -1311,6 +1313,7 @@ Array [
13111313
"replies",
13121314
"status",
13131315
"type",
1316+
"nodeType",
13141317
"parent",
13151318
"children",
13161319
"internal",
@@ -1325,6 +1328,7 @@ Array [
13251328
"id",
13261329
"name",
13271330
"url",
1331+
"nodeType",
13281332
"parent",
13291333
"children",
13301334
"internal",
@@ -1533,6 +1537,7 @@ Array [
15331537
"id",
15341538
"name",
15351539
"url",
1540+
"nodeType",
15361541
"parent",
15371542
"children",
15381543
"internal",
@@ -1634,6 +1639,7 @@ Array [
16341639
"slug",
16351640
"status",
16361641
"uri",
1642+
"nodeType",
16371643
"parent",
16381644
"children",
16391645
"internal",
@@ -1801,6 +1807,7 @@ Array [
18011807
"showInRest",
18021808
"showUi",
18031809
"uri",
1810+
"nodeType",
18041811
"parent",
18051812
"children",
18061813
"internal",
@@ -5800,6 +5807,7 @@ Array [
58005807
"slug",
58015808
"status",
58025809
"uri",
5810+
"nodeType",
58035811
"parent",
58045812
"children",
58055813
"internal",
@@ -5916,6 +5924,7 @@ Array [
59165924
"id",
59175925
"parentDatabaseId",
59185926
"parentId",
5927+
"nodeType",
59195928
"parent",
59205929
"children",
59215930
"internal",
@@ -5989,6 +5998,7 @@ Array [
59895998
"termGroupId",
59905999
"termTaxonomyId",
59916000
"uri",
6001+
"nodeType",
59926002
"parent",
59936003
"children",
59946004
"internal",
@@ -6111,6 +6121,7 @@ Array [
61116121
"status",
61126122
"title",
61136123
"uri",
6124+
"nodeType",
61146125
"localFile",
61156126
"parent",
61166127
"children",
@@ -6275,6 +6286,7 @@ Array [
62756286
"menuItems",
62766287
"name",
62776288
"slug",
6289+
"nodeType",
62786290
"parent",
62796291
"children",
62806292
"internal",
@@ -6359,6 +6371,7 @@ Array [
63596371
"title",
63606372
"uri",
63616373
"url",
6374+
"nodeType",
63626375
"parent",
63636376
"children",
63646377
"internal",
@@ -6434,6 +6447,7 @@ Array [
64346447
"isContentNode",
64356448
"isTermNode",
64366449
"uri",
6450+
"nodeType",
64376451
"parent",
64386452
"children",
64396453
"internal",
@@ -6608,6 +6622,7 @@ Array [
66086622
"authorDatabaseId",
66096623
"authorId",
66106624
"id",
6625+
"nodeType",
66116626
"parent",
66126627
"children",
66136628
"internal",
@@ -6687,6 +6702,7 @@ Array [
66876702
"commentCount",
66886703
"commentStatus",
66896704
"id",
6705+
"nodeType",
66906706
"parent",
66916707
"children",
66926708
"internal",
@@ -6747,6 +6763,7 @@ Array [
67476763
"fields": Array [
67486764
"content",
67496765
"id",
6766+
"nodeType",
67506767
"parent",
67516768
"children",
67526769
"internal",
@@ -6807,6 +6824,7 @@ Array [
68076824
"fields": Array [
68086825
"excerpt",
68096826
"id",
6827+
"nodeType",
68106828
"parent",
68116829
"children",
68126830
"internal",
@@ -6869,6 +6887,7 @@ Array [
68696887
"featuredImageDatabaseId",
68706888
"featuredImageId",
68716889
"id",
6890+
"nodeType",
68726891
"parent",
68736892
"children",
68746893
"internal",
@@ -6947,6 +6966,7 @@ Array [
69476966
"fields": Array [
69486967
"id",
69496968
"menuOrder",
6969+
"nodeType",
69506970
"parent",
69516971
"children",
69526972
"internal",
@@ -7007,6 +7027,7 @@ Array [
70077027
"fields": Array [
70087028
"id",
70097029
"isRevision",
7030+
"nodeType",
70107031
"parent",
70117032
"children",
70127033
"internal",
@@ -7072,6 +7093,7 @@ Array [
70727093
Object {
70737094
"fields": Array [
70747095
"id",
7096+
"nodeType",
70757097
"parent",
70767098
"children",
70777099
"internal",
@@ -7132,6 +7154,7 @@ Array [
71327154
"fields": Array [
71337155
"id",
71347156
"title",
7157+
"nodeType",
71357158
"parent",
71367159
"children",
71377160
"internal",
@@ -7194,6 +7217,7 @@ Array [
71947217
"pingStatus",
71957218
"pinged",
71967219
"toPing",
7220+
"nodeType",
71977221
"parent",
71987222
"children",
71997223
"internal",
@@ -7303,6 +7327,7 @@ Array [
73037327
"template",
73047328
"title",
73057329
"uri",
7330+
"nodeType",
73067331
"beforeChangeNodeTest",
73077332
"parent",
73087333
"children",
@@ -7577,6 +7602,7 @@ Array [
75777602
"title",
75787603
"toPing",
75797604
"uri",
7605+
"nodeType",
75807606
"beforeChangeNodeTest",
75817607
"parent",
75827608
"children",
@@ -7649,6 +7675,7 @@ Array [
76497675
"termGroupId",
76507676
"termTaxonomyId",
76517677
"uri",
7678+
"nodeType",
76527679
"parent",
76537680
"children",
76547681
"internal",
@@ -8019,6 +8046,7 @@ Array [
80198046
"template",
80208047
"title",
80218048
"uri",
8049+
"nodeType",
80228050
"parent",
80238051
"children",
80248052
"internal",
@@ -8716,6 +8744,7 @@ Array [
87168744
"termGroupId",
87178745
"termTaxonomyId",
87188746
"uri",
8747+
"nodeType",
87198748
"parent",
87208749
"children",
87218750
"internal",
@@ -8864,6 +8893,7 @@ Array [
88648893
"showInQuickEdit",
88658894
"showInRest",
88668895
"showUi",
8896+
"nodeType",
88678897
"parent",
88688898
"children",
88698899
"internal",
@@ -9010,6 +9040,7 @@ Array [
90109040
"termGroupId",
90119041
"termTaxonomyId",
90129042
"uri",
9043+
"nodeType",
90139044
"parent",
90149045
"children",
90159046
"internal",
@@ -9122,6 +9153,7 @@ Array [
91229153
"template",
91239154
"title",
91249155
"uri",
9156+
"nodeType",
91259157
"parent",
91269158
"children",
91279159
"internal",
@@ -9228,6 +9260,7 @@ Array [
92289260
"template",
92299261
"title",
92309262
"uri",
9263+
"nodeType",
92319264
"parent",
92329265
"children",
92339266
"internal",
@@ -9334,6 +9367,7 @@ Array [
93349367
"template",
93359368
"title",
93369369
"uri",
9370+
"nodeType",
93379371
"parent",
93389372
"children",
93399373
"internal",
@@ -9412,6 +9446,7 @@ Array [
94129446
"isContentNode",
94139447
"isTermNode",
94149448
"uri",
9449+
"nodeType",
94159450
"parent",
94169451
"children",
94179452
"internal",
@@ -9495,6 +9530,7 @@ Array [
94959530
"uri",
94969531
"url",
94979532
"username",
9533+
"nodeType",
94989534
"parent",
94999535
"children",
95009536
"internal",
@@ -9565,6 +9601,7 @@ Array [
95659601
"displayName",
95669602
"id",
95679603
"name",
9604+
"nodeType",
95689605
"parent",
95699606
"children",
95709607
"internal",

packages/gatsby-source-wordpress/src/steps/create-schema-customization/index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ const customizeSchema = async ({ actions, schema, store: gatsbyStore }) => {
6767
break
6868
}
6969

70-
if (type.interfaces && builtType?.config) {
71-
builtType.config.interfaces ||= []
72-
builtType.config.interfaces.push(...buildInterfacesListForType(type))
73-
}
74-
7570
if (builtType) {
7671
typeDefs.push(builtType)
7772
}

packages/gatsby-source-wordpress/src/steps/create-schema-customization/type-filters.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
import { buildInterfacesListForType } from "./helpers"
2+
13
export const typeDefinitionFilters = [
24
{
35
typeName: `__all`,
4-
typeDef: typeDef => {
5-
/**
6-
* @todo once WPGraphQL has a DateTime Scalar, use that to find date fields
7-
* instead of the below fieldnames
8-
*/
6+
typeDef: (typeDef, { type }) => {
7+
if (type.interfaces && typeDef) {
8+
typeDef.interfaces ||= []
9+
typeDef.interfaces.push(...buildInterfacesListForType(type))
10+
}
11+
12+
if (typeDef?.interfaces?.includes(`Node`)) {
13+
// used to filter by different node types within a node interface
14+
typeDef.fields.nodeType = `String`
15+
}
916

1017
if (typeDef?.fields?.date) {
1118
const dateField = {

0 commit comments

Comments
 (0)