const fs = require(`fs-extra`)

exports.onCreateNode = require(`./on-node-create`)
exports.setFieldsOnGraphQLNodeType = require(`./extend-node-type`)

exports.onPreExtractQueries = async ({ store, getNodesByType }) => {
  const program = store.getState().program

  // Check if there are any ImageSharp nodes. If so add fragments for ImageSharp.
  // The fragment will cause an error if there are no ImageSharp nodes.
  if (getNodesByType(`ImageSharp`).length == 0) {
    return
  }

  // We have ImageSharp nodes so let's add our fragments to .cache/fragments.
  await fs.copy(
    require.resolve(`gatsby-transformer-sharp/src/fragments.js`),
    `${program.directory}/.cache/fragments/image-sharp-fragments.js`
  )
}

@@ -713,8 +713,208 @@
 %60%0A  )%0A%7D%0A
+%0Aexports.sourceNodes = (%7B actions %7D) =%3E %7B%0A  const %7B createTypes %7D = actions%0A%0A  if (createTypes) %7B%0A    createTypes(%60%0A      type ImageSharp implements Node @infer %7B%0A        id: ID!%0A      %7D%0A    %60)%0A  %7D%0A%7D%0A

Add default types for ImageSha… (#15285)