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)

* 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)
  • Loading branch information
TylerBarnes authored and pieh committed Dec 8, 2022
1 parent 188d3e7 commit ede7366
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 @@ -1082,6 +1083,7 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1231,6 +1233,7 @@ Array [
"replies",
"status",
"type",
"nodeType",
"parent",
"children",
"internal",
Expand All @@ -1245,6 +1248,7 @@ Array [
"id",
"name",
"url",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1421,6 +1425,7 @@ Array [
"id",
"name",
"url",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1522,6 +1527,7 @@ Array [
"slug",
"status",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -1665,6 +1671,7 @@ Array [
"showInRest",
"showUi",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5632,6 +5639,7 @@ Array [
"slug",
"status",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5724,6 +5732,7 @@ Array [
"id",
"parentDatabaseId",
"parentId",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5797,6 +5806,7 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -5911,6 +5921,7 @@ Array [
"status",
"title",
"uri",
"nodeType",
"localFile",
"parent",
"children",
Expand Down Expand Up @@ -6051,6 +6062,7 @@ Array [
"menuItems",
"name",
"slug",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6135,6 +6147,7 @@ Array [
"title",
"uri",
"url",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6210,6 +6223,7 @@ Array [
"isContentNode",
"isTermNode",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6344,6 +6358,7 @@ Array [
"authorDatabaseId",
"authorId",
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6415,6 +6430,7 @@ Array [
"commentCount",
"commentStatus",
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6475,6 +6491,7 @@ Array [
"fields": Array [
"content",
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6535,6 +6552,7 @@ Array [
"fields": Array [
"excerpt",
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6597,6 +6615,7 @@ Array [
"featuredImageDatabaseId",
"featuredImageId",
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6667,6 +6686,7 @@ Array [
"fields": Array [
"id",
"menuOrder",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6727,6 +6747,7 @@ Array [
"fields": Array [
"id",
"isRevision",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6792,6 +6813,7 @@ Array [
Object {
"fields": Array [
"id",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6852,6 +6874,7 @@ Array [
"fields": Array [
"id",
"title",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -6914,6 +6937,7 @@ Array [
"pingStatus",
"pinged",
"toPing",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7023,6 +7047,7 @@ Array [
"template",
"title",
"uri",
"nodeType",
"beforeChangeNodeTest",
"parent",
"children",
Expand Down Expand Up @@ -7265,6 +7290,7 @@ Array [
"title",
"toPing",
"uri",
"nodeType",
"beforeChangeNodeTest",
"parent",
"children",
Expand Down Expand Up @@ -7337,6 +7363,7 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -7619,6 +7646,7 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8100,6 +8128,7 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8224,6 +8253,7 @@ Array [
"showInQuickEdit",
"showInRest",
"showUi",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8354,6 +8384,7 @@ Array [
"termGroupId",
"termTaxonomyId",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8466,6 +8497,7 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8572,6 +8604,7 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8678,6 +8711,7 @@ Array [
"template",
"title",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8756,6 +8790,7 @@ Array [
"isContentNode",
"isTermNode",
"uri",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8839,6 +8874,7 @@ Array [
"uri",
"url",
"username",
"nodeType",
"parent",
"children",
"internal",
Expand Down Expand Up @@ -8909,6 +8945,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 ede7366

Please sign in to comment.