Skip to content

Commit

Permalink
make gatsby-plugin-image a dependency again and warn users about the …
Browse files Browse the repository at this point in the history
…beta feature
  • Loading branch information
axe312ger committed Dec 22, 2020
1 parent 12c7ac8 commit 7788f06
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
1 change: 1 addition & 0 deletions packages/gatsby-source-contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"contentful": "^7.14.12",
"fs-extra": "^9.0.1",
"gatsby-core-utils": "^1.8.0-next.0",
"gatsby-plugin-image": "^0.4.0-next.3",
"gatsby-plugin-utils": "^0.7.0-next.1",
"gatsby-source-filesystem": "^2.9.0-next.1",
"is-online": "^8.5.1",
Expand Down
26 changes: 13 additions & 13 deletions packages/gatsby-source-contentful/src/extend-node-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const {
} = require(`gatsby/graphql`)
const qs = require(`qs`)
const base64Img = require(`base64-img`)
const { generateImageData } = require(`gatsby-plugin-image`)
const { getGatsbyImageFieldConfig } = require(`gatsby-plugin-image/graphql`)
const { stripIndent } = require(`common-tags`)

const cacheImage = require(`./cache-image`)

Expand Down Expand Up @@ -190,7 +193,6 @@ const fitMap = new Map([
])

const resolveGatsbyImageData = async (image, options) => {
const { generateImageData } = require(`gatsby-plugin-image`)
const { baseUrl, ...sourceMetadata } = getBasicImageProps(image, options)

return generateImageData({
Expand Down Expand Up @@ -646,7 +648,9 @@ const fluidNodeType = ({ name, getTracedSVG }) => {
}
}

exports.extendNodeType = ({ type, store }) => {
let warnedForBeta = false

exports.extendNodeType = ({ type, store, reporter }) => {
if (type.name !== `ContentfulAsset`) {
return {}
}
Expand Down Expand Up @@ -690,19 +694,15 @@ exports.extendNodeType = ({ type, store }) => {
const sizesNode = fluidNodeType({ name: `ContentfulSizes`, getTracedSVG })
sizesNode.deprecationReason = `Sizes was deprecated in Gatsby v2. It's been renamed to "fluid" https://example.com/write-docs-and-fix-this-example-link`

// gatsby-pugin-image
// gatsby-plugin-image
const getGatsbyImageData = () => {
// @todo check if gatsby-plugin-image is enabled
const gatsbyImageEnabled = false
if (!gatsbyImageEnabled) {
return {
type: GraphQLString,
deprecated: true,
deprecationReason: `Enable gatsby-plugin-image to use this field.`,
resolve: () => null,
}
if (!warnedForBeta) {
reporter.warn(
stripIndent`
Thank you for trying the beta version of the \`gatsbyImageData\` API. Please provide feedback and report any issues at: https://github.com/gatsbyjs/gatsby/discussions/27950`
)
warnedForBeta = true
}
const { getGatsbyImageFieldConfig } = require(`gatsby-plugin-image/graphql`)

return getGatsbyImageFieldConfig(resolveGatsbyImageData, {
jpegProgressive: {
Expand Down

0 comments on commit 7788f06

Please sign in to comment.