-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby-transformer-sharp): Add default types for ImageSharp #15285
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the fragments work if the types only have ID? We might need to add full type definitions. Also I'm worried about other types that aren't defined.
@@ -43,7 +43,15 @@ exports.sourceNodes = ( | |||
{ actions, getNode, createNodeId, hasNodeChanged, reporter, emitter }, | |||
pluginOptions | |||
) => { | |||
const { createNode, deleteNode } = actions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use createSchemaCustomization
instead of sourceNodes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we would use createSchemaCustomization
here, users would be required to run at least gatsby@2.12.0
and it will inevitably cause issues for people updating just plugin and not core gatsby package.
IMO, if this is just more correct API to use, but doesn't ultimately change how things work, it's just safer to keep it in sourceNodes
(at least until we need to do major release for that plugin where we can bump minimal supported Gatsby version without interupting users)
@@ -18,3 +18,15 @@ exports.onPreExtractQueries = async ({ store, getNodesByType }) => { | |||
`${program.directory}/.cache/fragments/image-sharp-fragments.js` | |||
) | |||
} | |||
|
|||
exports.sourceNodes = ({ actions }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto about createSchemaCustomization
.
Co-Authored-By: Mikhail Novikov <freiksenet@gmail.com>
Published in |
Now that themes is almost ready to go, we've surfaced upon an issue in ChristopherBiscardi/gatsby-themes-stable-test#1 where a theme without any content will break with
This occurs because the node the above definition is trying to create a fragment on (
ImageSharp
) doesn't exist because no image file was present in the project.To fix this, we need to add default types for
ImageSharp
,File
and more in the respective plugins that own them.CC @freiksenet @pieh @KyleAMathews