just curious about any solutions which would help to reduce the pressure on the images query inside the Gatsby website. Gatsby already gives a warning that images query takes too long (we have around 600 images inside the website and it is growing quite fast).
Ideally I would like to fetch just a specific image each time, but do not really want to create static queries for each of them.
As of now, my query inside Image
component is like this:
query={graphql`
{
images: allFile(filter: { sourceInstanceName: { eq: "images" } }) {
edges {
node {
relativePath
name
childImageSharp {
gatsbyImageData(
quality: 100
layout: CONSTRAINED
placeholder: TRACED_SVG
)
}
}
}
}
}
`}
render={data => {
const image = data.images.edges.find(n => {
return n.node.relativePath.includes(filename);
});
if (!image) {
return null;
}
const imageAlt = filename.split('.')[0];
return (
<GatsbyImage
image={image.node.childImageSharp.gatsbyImageData}
className={className}
style={styles}
alt={alt ? alt : imageAlt}
fadeIn={false}
/>
);
}}
/>
I just want to hear any solutions anyone came up to work with for larger image databases on Gatsby :)