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

chore(gatsby-source-contentful): drop unnecessary promise, _.get #28439

Merged
merged 2 commits into from
Dec 2, 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
60 changes: 30 additions & 30 deletions packages/gatsby-source-contentful/src/extend-node-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ const fixedNodeType = ({ name, getTracedSVG }) => {
type: GraphQLString,
resolve({ image, options, context }) {
if (
_.get(image, `file.contentType`) === `image/webp` ||
image?.file?.contentType === `image/webp` ||
options.toFormat === `webp`
) {
return null
Expand All @@ -390,14 +390,14 @@ const fixedNodeType = ({ name, getTracedSVG }) => {
...options,
toFormat: `webp`,
})
return _.get(fixed, `src`)
return fixed?.src
},
},
srcSetWebp: {
type: GraphQLString,
resolve({ image, options, context }) {
if (
_.get(image, `file.contentType`) === `image/webp` ||
image?.file?.contentType === `image/webp` ||
options.toFormat === `webp`
) {
return null
Expand All @@ -407,7 +407,7 @@ const fixedNodeType = ({ name, getTracedSVG }) => {
...options,
toFormat: `webp`,
})
return _.get(fixed, `srcSet`)
return fixed?.srcSet
},
},
},
Expand Down Expand Up @@ -439,17 +439,17 @@ const fixedNodeType = ({ name, getTracedSVG }) => {
defaultValue: null,
},
},
resolve: (image, options, context) =>
Promise.resolve(resolveFixed(image, options)).then(node => {
if (!node) return null

return {
...node,
image,
options,
context,
}
}),
resolve(image, options, context) {
const node = resolveFixed(image, options)
if (!node) return null

return {
...node,
image,
options,
context,
}
},
}
}

Expand All @@ -475,7 +475,7 @@ const fluidNodeType = ({ name, getTracedSVG }) => {
type: GraphQLString,
resolve({ image, options, context }) {
if (
_.get(image, `file.contentType`) === `image/webp` ||
image?.file?.contentType === `image/webp` ||
options.toFormat === `webp`
) {
return null
Expand All @@ -485,14 +485,14 @@ const fluidNodeType = ({ name, getTracedSVG }) => {
...options,
toFormat: `webp`,
})
return _.get(fluid, `src`)
return fluid?.src
},
},
srcSetWebp: {
type: GraphQLString,
resolve({ image, options, context }) {
if (
_.get(image, `file.contentType`) === `image/webp` ||
image?.file?.contentType === `image/webp` ||
options.toFormat === `webp`
) {
return null
Expand All @@ -502,7 +502,7 @@ const fluidNodeType = ({ name, getTracedSVG }) => {
...options,
toFormat: `webp`,
})
return _.get(fluid, `srcSet`)
return fluid?.srcSet
},
},
sizes: { type: new GraphQLNonNull(GraphQLString) },
Expand Down Expand Up @@ -538,17 +538,17 @@ const fluidNodeType = ({ name, getTracedSVG }) => {
type: GraphQLString,
},
},
resolve: (image, options, context) =>
Promise.resolve(resolveFluid(image, options)).then(node => {
if (!node) return null

return {
...node,
image,
options,
context,
}
}),
resolve(image, options, context) {
const node = resolveFluid(image, options)
if (!node) return null

return {
...node,
image,
options,
context,
}
},
}
}

Expand Down