Skip to content

Commit

Permalink
fix(gatsby-source-wordpress): Add back nodeType field that was remove…
Browse files Browse the repository at this point in the history
…d in last version (#37212) (#37219)

* 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

(cherry picked from commit b7d7b07)

Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
  • Loading branch information
gatsbybot and TylerBarnes authored Dec 8, 2022
1 parent 866aa49 commit 815791a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ Array [
"seo",
"viewer",
"writingSettings",
"nodeType",
"id",
"parent",
"children",
Expand Down Expand Up @@ -1114,6 +1115,7 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1311,6 +1313,7 @@ Array [
"replies",
"status",
"type",
"nodeType",
"parent",
"children",
"internal",
Expand All @@ -1325,6 +1328,7 @@ Array [
"id",
"name",
"url",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1533,6 +1537,7 @@ Array [
"id",
"name",
"url",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1634,6 +1639,7 @@ Array [
"slug",
"status",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1801,6 +1807,7 @@ Array [
"showInRest",
"showUi",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5800,6 +5807,7 @@ Array [
"slug",
"status",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5916,6 +5924,7 @@ Array [
"id",
"parentDatabaseId",
"parentId",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5989,6 +5998,7 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6111,6 +6121,7 @@ Array [
"status",
"title",
"uri",
"nodeType",
"localFile",
"parent",
"children",
Expand Down Expand Up @@ -6275,6 +6286,7 @@ Array [
"menuItems",
"name",
"slug",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6359,6 +6371,7 @@ Array [
"title",
"uri",
"url",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6434,6 +6447,7 @@ Array [
"isContentNode",
"isTermNode",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6608,6 +6622,7 @@ Array [
"authorDatabaseId",
"authorId",
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6687,6 +6702,7 @@ Array [
"commentCount",
"commentStatus",
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6747,6 +6763,7 @@ Array [
"fields": Array [
"content",
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6807,6 +6824,7 @@ Array [
"fields": Array [
"excerpt",
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6869,6 +6887,7 @@ Array [
"featuredImageDatabaseId",
"featuredImageId",
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6947,6 +6966,7 @@ Array [
"fields": Array [
"id",
"menuOrder",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7007,6 +7027,7 @@ Array [
"fields": Array [
"id",
"isRevision",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7072,6 +7093,7 @@ Array [
Object {
"fields": Array [
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7132,6 +7154,7 @@ Array [
"fields": Array [
"id",
"title",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7194,6 +7217,7 @@ Array [
"pingStatus",
"pinged",
"toPing",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7303,6 +7327,7 @@ Array [
"template",
"title",
"uri",
"nodeType",
"beforeChangeNodeTest",
"parent",
"children",
Expand Down Expand Up @@ -7577,6 +7602,7 @@ Array [
"title",
"toPing",
"uri",
"nodeType",
"beforeChangeNodeTest",
"parent",
"children",
Expand Down Expand Up @@ -7649,6 +7675,7 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8019,6 +8046,7 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8716,6 +8744,7 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8864,6 +8893,7 @@ Array [
"showInQuickEdit",
"showInRest",
"showUi",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -9010,6 +9040,7 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -9122,6 +9153,7 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -9228,6 +9260,7 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -9334,6 +9367,7 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -9412,6 +9446,7 @@ Array [
"isContentNode",
"isTermNode",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -9495,6 +9530,7 @@ Array [
"uri",
"url",
"username",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -9565,6 +9601,7 @@ Array [
"displayName",
"id",
"name",
"nodeType",
"parent",
"children",
"internal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ const customizeSchema = async ({ actions, schema, store: gatsbyStore }) => {
break
}

if (type.interfaces && builtType?.config) {
builtType.config.interfaces ||= []
builtType.config.interfaces.push(...buildInterfacesListForType(type))
}

if (builtType) {
typeDefs.push(builtType)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
import { buildInterfacesListForType } from "./helpers"

export const typeDefinitionFilters = [
{
typeName: `__all`,
typeDef: typeDef => {
/**
* @todo once WPGraphQL has a DateTime Scalar, use that to find date fields
* instead of the below fieldnames
*/
typeDef: (typeDef, { type }) => {
if (type.interfaces && typeDef) {
typeDef.interfaces ||= []
typeDef.interfaces.push(...buildInterfacesListForType(type))
}

if (typeDef?.interfaces?.includes(`Node`)) {
// used to filter by different node types within a node interface
typeDef.fields.nodeType = `String`
}

if (typeDef?.fields?.date) {
const dateField = {
Expand Down

0 comments on commit 815791a

Please sign in to comment.