Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-source-wordpress): bug patch for issue 35460 #35817

Merged
merged 2 commits into from Jun 1, 2022

Conversation

tsdexter
Copy link
Contributor

@tsdexter tsdexter commented Jun 1, 2022

Description

Check the pluginOptions.type.MediaItem.exclude before fetching referenced media items during page updates

Documentation

Related Issues

Fixes #35460

…e.MediaItem.exclude` is `true` during updates
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 1, 2022
…-nodes/wp-actions/update.js

Co-authored-by: Tyler Barnes <tylerdbarnes@gmail.com>
@TylerBarnes TylerBarnes self-requested a review June 1, 2022 16:39
Copy link
Contributor

@TylerBarnes TylerBarnes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for this @tsdexter !

@TylerBarnes TylerBarnes merged commit 299ad95 into gatsbyjs:master Jun 1, 2022
@TylerBarnes TylerBarnes removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 1, 2022
@tsdexter
Copy link
Contributor Author

tsdexter commented Jun 1, 2022

no problem @TylerBarnes ... happy to be able to contribute

ps. I noticed there are a few other places where fetchReferencedMediaItemsAndCreateNodes is called without any option checks... none of them affected my issue and I'm not fully aware of the context in which they're called so I didn't add any plug-in option checks around the ones unrelated to my specific issue.

@TylerBarnes
Copy link
Contributor

Good to know, thanks for calling that out! Always open to a PR for those ;) but otherwise I'll make a note to remember to add those checks. Thanks again!

@tsdexter
Copy link
Contributor Author

tsdexter commented Jun 2, 2022

@TylerBarnes would it make sense to localize the check into the function? If so, I can do that and cleanup the other individual checks.

Something like:

export default async function fetchReferencedMediaItemsAndCreateNodes({
  referencedMediaItemNodeIds,
  mediaItemUrls,
}) {
  const state = store.getState()
  const queryInfo = state.remoteSchema.nodeQueries.mediaItems
  const { helpers, pluginOptions } = state.gatsbyApi

  if (pluginOptions.type.MediaItem.exclude) return []

  const { createContentDigest, actions } = helpers
  const { url } = pluginOptions
  const { typeInfo, settings, selectionSet, builtFragments } = queryInfo
...

@TylerBarnes
Copy link
Contributor

Yeah, that seems reasonable 👍

@tsdexter
Copy link
Contributor Author

tsdexter commented Jun 2, 2022

@TylerBarnes #35827

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[gatsby-source-wordpress] Cannot destructure property 'typeInfo' of 'queryInfo' as it is undefined.
2 participants