Skip to content

Commit

Permalink
refactor: flatten Contentful asset data structure to match GraphQL AP…
Browse files Browse the repository at this point in the history
…I schema (#31115)
  • Loading branch information
axe312ger committed Jun 10, 2021
1 parent 8986f7b commit 102a1af
Show file tree
Hide file tree
Showing 10 changed files with 604 additions and 1,152 deletions.
26 changes: 12 additions & 14 deletions e2e-tests/contentful/src/pages/gatsby-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const GatsbyImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
{node.fluid ? (
<GatsbyImage fluid={node.fluid} />
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand All @@ -35,14 +35,14 @@ const GatsbyImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
{node.fixed ? (
<GatsbyImage fixed={node.fixed} />
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand All @@ -54,14 +54,14 @@ const GatsbyImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
{node.webp ? (
<GatsbyImage fixed={node.webp} />
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand All @@ -73,14 +73,14 @@ const GatsbyImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
{node.traced ? (
<GatsbyImage fixed={node.traced} />
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand All @@ -92,7 +92,7 @@ const GatsbyImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
Expand All @@ -104,7 +104,7 @@ const GatsbyImagePage = ({ data }) => {
}}
/>
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand Down Expand Up @@ -173,10 +173,8 @@ export const pageQuery = graphql`
nodes {
title
description
file {
fileName
url
}
fileName
url
fluid(maxWidth: 420) {
...GatsbyContentfulFluid
}
Expand Down
34 changes: 16 additions & 18 deletions e2e-tests/contentful/src/pages/gatsby-plugin-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ const GatsbyPluginImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
{node.constrained ? (
<GatsbyImage image={node.constrained} />
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand All @@ -34,14 +34,14 @@ const GatsbyPluginImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
{node.fullWidth ? (
<GatsbyImage image={node.fullWidth} />
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand All @@ -53,14 +53,14 @@ const GatsbyPluginImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
{node.fixed ? (
<GatsbyImage image={node.fixed} />
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand All @@ -72,14 +72,14 @@ const GatsbyPluginImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
{node.dominantColor ? (
<GatsbyImage image={node.dominantColor} />
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand All @@ -91,14 +91,14 @@ const GatsbyPluginImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
{node.traced ? (
<GatsbyImage image={node.traced} />
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand All @@ -110,14 +110,14 @@ const GatsbyPluginImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
{node.blurred ? (
<GatsbyImage image={node.blurred} />
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand All @@ -129,7 +129,7 @@ const GatsbyPluginImagePage = ({ data }) => {
<div>
<p>
<strong>
{node.title} ({node.file.fileName.split(".").pop()})
{node.title} ({node.fileName.split(".").pop()})
</strong>
</p>
{node.description && <p>{node.description}</p>}
Expand All @@ -143,7 +143,7 @@ const GatsbyPluginImagePage = ({ data }) => {
}}
/>
) : (
<SvgImage src={node.file.url} />
<SvgImage src={node.url} />
)}
</div>
))}
Expand Down Expand Up @@ -212,10 +212,8 @@ export const pageQuery = graphql`
nodes {
title
description
file {
fileName
url
}
fileName
url
constrained: gatsbyImageData(width: 420)
fullWidth: gatsbyImageData(width: 200, layout: FIXED)
fixed: gatsbyImageData(width: 200, layout: FIXED)
Expand Down
Loading

0 comments on commit 102a1af

Please sign in to comment.