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-contentful): Bypass schema validation for null nodes for fixed/fluid media assets #20794

Merged
merged 1 commit into from
Jan 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/gatsby-source-contentful/src/extend-node-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,8 @@ const fixedNodeType = ({ name, getTracedSVG }) => {
},
resolve: (image, options, context) =>
Promise.resolve(resolveFixed(image, options)).then(node => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm looking at this and I'm convinced it could just be

resolve: (image, options, context) =>
  Promise.resolve(resolveFixed(image, options)).then(node => {

into

resolve: async (image, options, context) =>
  const node = resolveFixed(image, options)

And it would be the same thing. The resolveFixed func is never returning a promise so there's no need (anymore?) for the Promise.resolve. The async keyword will ensure a promise is returned to preserve that api.

Not sure if it makes any difference but would be clearer. Oh well, this was unrelated to this PR, I was just confused looking at it :)

if (!node) return null

return {
...node,
image,
Expand Down Expand Up @@ -494,6 +496,8 @@ const fluidNodeType = ({ name, getTracedSVG }) => {
},
resolve: (image, options, context) =>
Promise.resolve(resolveFluid(image, options)).then(node => {
if (!node) return null

return {
...node,
image,
Expand Down