diff --git a/integration-tests/gatsby-source-wordpress/__tests__/__snapshots__/index.js.snap b/integration-tests/gatsby-source-wordpress/__tests__/__snapshots__/index.js.snap index 8b59e8b779fad..ff4ce39cfd37d 100644 --- a/integration-tests/gatsby-source-wordpress/__tests__/__snapshots__/index.js.snap +++ b/integration-tests/gatsby-source-wordpress/__tests__/__snapshots__/index.js.snap @@ -951,6 +951,7 @@ Array [ "seo", "viewer", "writingSettings", + "nodeType", "id", "parent", "children", @@ -1082,6 +1083,7 @@ Array [ "termGroupId", "termTaxonomyId", "uri", + "nodeType", "parent", "children", "internal", @@ -1231,6 +1233,7 @@ Array [ "replies", "status", "type", + "nodeType", "parent", "children", "internal", @@ -1245,6 +1248,7 @@ Array [ "id", "name", "url", + "nodeType", "parent", "children", "internal", @@ -1421,6 +1425,7 @@ Array [ "id", "name", "url", + "nodeType", "parent", "children", "internal", @@ -1522,6 +1527,7 @@ Array [ "slug", "status", "uri", + "nodeType", "parent", "children", "internal", @@ -1665,6 +1671,7 @@ Array [ "showInRest", "showUi", "uri", + "nodeType", "parent", "children", "internal", @@ -5632,6 +5639,7 @@ Array [ "slug", "status", "uri", + "nodeType", "parent", "children", "internal", @@ -5724,6 +5732,7 @@ Array [ "id", "parentDatabaseId", "parentId", + "nodeType", "parent", "children", "internal", @@ -5797,6 +5806,7 @@ Array [ "termGroupId", "termTaxonomyId", "uri", + "nodeType", "parent", "children", "internal", @@ -5911,6 +5921,7 @@ Array [ "status", "title", "uri", + "nodeType", "localFile", "parent", "children", @@ -6051,6 +6062,7 @@ Array [ "menuItems", "name", "slug", + "nodeType", "parent", "children", "internal", @@ -6135,6 +6147,7 @@ Array [ "title", "uri", "url", + "nodeType", "parent", "children", "internal", @@ -6210,6 +6223,7 @@ Array [ "isContentNode", "isTermNode", "uri", + "nodeType", "parent", "children", "internal", @@ -6344,6 +6358,7 @@ Array [ "authorDatabaseId", "authorId", "id", + "nodeType", "parent", "children", "internal", @@ -6415,6 +6430,7 @@ Array [ "commentCount", "commentStatus", "id", + "nodeType", "parent", "children", "internal", @@ -6475,6 +6491,7 @@ Array [ "fields": Array [ "content", "id", + "nodeType", "parent", "children", "internal", @@ -6535,6 +6552,7 @@ Array [ "fields": Array [ "excerpt", "id", + "nodeType", "parent", "children", "internal", @@ -6597,6 +6615,7 @@ Array [ "featuredImageDatabaseId", "featuredImageId", "id", + "nodeType", "parent", "children", "internal", @@ -6667,6 +6686,7 @@ Array [ "fields": Array [ "id", "menuOrder", + "nodeType", "parent", "children", "internal", @@ -6727,6 +6747,7 @@ Array [ "fields": Array [ "id", "isRevision", + "nodeType", "parent", "children", "internal", @@ -6792,6 +6813,7 @@ Array [ Object { "fields": Array [ "id", + "nodeType", "parent", "children", "internal", @@ -6852,6 +6874,7 @@ Array [ "fields": Array [ "id", "title", + "nodeType", "parent", "children", "internal", @@ -6914,6 +6937,7 @@ Array [ "pingStatus", "pinged", "toPing", + "nodeType", "parent", "children", "internal", @@ -7023,6 +7047,7 @@ Array [ "template", "title", "uri", + "nodeType", "beforeChangeNodeTest", "parent", "children", @@ -7265,6 +7290,7 @@ Array [ "title", "toPing", "uri", + "nodeType", "beforeChangeNodeTest", "parent", "children", @@ -7337,6 +7363,7 @@ Array [ "termGroupId", "termTaxonomyId", "uri", + "nodeType", "parent", "children", "internal", @@ -7619,6 +7646,7 @@ Array [ "template", "title", "uri", + "nodeType", "parent", "children", "internal", @@ -8100,6 +8128,7 @@ Array [ "termGroupId", "termTaxonomyId", "uri", + "nodeType", "parent", "children", "internal", @@ -8224,6 +8253,7 @@ Array [ "showInQuickEdit", "showInRest", "showUi", + "nodeType", "parent", "children", "internal", @@ -8354,6 +8384,7 @@ Array [ "termGroupId", "termTaxonomyId", "uri", + "nodeType", "parent", "children", "internal", @@ -8466,6 +8497,7 @@ Array [ "template", "title", "uri", + "nodeType", "parent", "children", "internal", @@ -8572,6 +8604,7 @@ Array [ "template", "title", "uri", + "nodeType", "parent", "children", "internal", @@ -8678,6 +8711,7 @@ Array [ "template", "title", "uri", + "nodeType", "parent", "children", "internal", @@ -8756,6 +8790,7 @@ Array [ "isContentNode", "isTermNode", "uri", + "nodeType", "parent", "children", "internal", @@ -8839,6 +8874,7 @@ Array [ "uri", "url", "username", + "nodeType", "parent", "children", "internal", @@ -8909,6 +8945,7 @@ Array [ "displayName", "id", "name", + "nodeType", "parent", "children", "internal", diff --git a/packages/gatsby-source-wordpress/src/steps/create-schema-customization/index.js b/packages/gatsby-source-wordpress/src/steps/create-schema-customization/index.js index 88ced3038a379..57afc366b99d9 100644 --- a/packages/gatsby-source-wordpress/src/steps/create-schema-customization/index.js +++ b/packages/gatsby-source-wordpress/src/steps/create-schema-customization/index.js @@ -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) } diff --git a/packages/gatsby-source-wordpress/src/steps/create-schema-customization/type-filters.js b/packages/gatsby-source-wordpress/src/steps/create-schema-customization/type-filters.js index 17f23ea92c7f8..85e6ab0dbb647 100644 --- a/packages/gatsby-source-wordpress/src/steps/create-schema-customization/type-filters.js +++ b/packages/gatsby-source-wordpress/src/steps/create-schema-customization/type-filters.js @@ -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 = {