Skip to content

Commit 9df2fd0

Browse files
committed
refactor: flatten Contentful asset data structure to match GraphQL API schema (#31115)
1 parent 7141a0a commit 9df2fd0

File tree

10 files changed

+604
-1152
lines changed

10 files changed

+604
-1152
lines changed

e2e-tests/contentful/src/pages/gatsby-image.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ const GatsbyImagePage = ({ data }) => {
1616
<div>
1717
<p>
1818
<strong>
19-
{node.title} ({node.file.fileName.split(".").pop()})
19+
{node.title} ({node.fileName.split(".").pop()})
2020
</strong>
2121
</p>
2222
{node.description && <p>{node.description}</p>}
2323
{node.fluid ? (
2424
<GatsbyImage fluid={node.fluid} />
2525
) : (
26-
<SvgImage src={node.file.url} />
26+
<SvgImage src={node.url} />
2727
)}
2828
</div>
2929
))}
@@ -35,14 +35,14 @@ const GatsbyImagePage = ({ data }) => {
3535
<div>
3636
<p>
3737
<strong>
38-
{node.title} ({node.file.fileName.split(".").pop()})
38+
{node.title} ({node.fileName.split(".").pop()})
3939
</strong>
4040
</p>
4141
{node.description && <p>{node.description}</p>}
4242
{node.fixed ? (
4343
<GatsbyImage fixed={node.fixed} />
4444
) : (
45-
<SvgImage src={node.file.url} />
45+
<SvgImage src={node.url} />
4646
)}
4747
</div>
4848
))}
@@ -54,14 +54,14 @@ const GatsbyImagePage = ({ data }) => {
5454
<div>
5555
<p>
5656
<strong>
57-
{node.title} ({node.file.fileName.split(".").pop()})
57+
{node.title} ({node.fileName.split(".").pop()})
5858
</strong>
5959
</p>
6060
{node.description && <p>{node.description}</p>}
6161
{node.webp ? (
6262
<GatsbyImage fixed={node.webp} />
6363
) : (
64-
<SvgImage src={node.file.url} />
64+
<SvgImage src={node.url} />
6565
)}
6666
</div>
6767
))}
@@ -73,14 +73,14 @@ const GatsbyImagePage = ({ data }) => {
7373
<div>
7474
<p>
7575
<strong>
76-
{node.title} ({node.file.fileName.split(".").pop()})
76+
{node.title} ({node.fileName.split(".").pop()})
7777
</strong>
7878
</p>
7979
{node.description && <p>{node.description}</p>}
8080
{node.traced ? (
8181
<GatsbyImage fixed={node.traced} />
8282
) : (
83-
<SvgImage src={node.file.url} />
83+
<SvgImage src={node.url} />
8484
)}
8585
</div>
8686
))}
@@ -92,7 +92,7 @@ const GatsbyImagePage = ({ data }) => {
9292
<div>
9393
<p>
9494
<strong>
95-
{node.title} ({node.file.fileName.split(".").pop()})
95+
{node.title} ({node.fileName.split(".").pop()})
9696
</strong>
9797
</p>
9898
{node.description && <p>{node.description}</p>}
@@ -104,7 +104,7 @@ const GatsbyImagePage = ({ data }) => {
104104
}}
105105
/>
106106
) : (
107-
<SvgImage src={node.file.url} />
107+
<SvgImage src={node.url} />
108108
)}
109109
</div>
110110
))}
@@ -134,10 +134,8 @@ export const pageQuery = graphql`
134134
nodes {
135135
title
136136
description
137-
file {
138-
fileName
139-
url
140-
}
137+
fileName
138+
url
141139
fluid(maxWidth: 420) {
142140
...GatsbyContentfulFluid
143141
}

e2e-tests/contentful/src/pages/gatsby-plugin-image.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ const GatsbyPluginImagePage = ({ data }) => {
1616
<div>
1717
<p>
1818
<strong>
19-
{node.title} ({node.file.fileName.split(".").pop()})
19+
{node.title} ({node.fileName.split(".").pop()})
2020
</strong>
2121
</p>
2222
{node.description && <p>{node.description}</p>}
2323
{node.constrained ? (
2424
<GatsbyImage image={node.constrained} />
2525
) : (
26-
<SvgImage src={node.file.url} />
26+
<SvgImage src={node.url} />
2727
)}
2828
</div>
2929
))}
@@ -34,14 +34,14 @@ const GatsbyPluginImagePage = ({ data }) => {
3434
<div>
3535
<p>
3636
<strong>
37-
{node.title} ({node.file.fileName.split(".").pop()})
37+
{node.title} ({node.fileName.split(".").pop()})
3838
</strong>
3939
</p>
4040
{node.description && <p>{node.description}</p>}
4141
{node.fullWidth ? (
4242
<GatsbyImage image={node.fullWidth} />
4343
) : (
44-
<SvgImage src={node.file.url} />
44+
<SvgImage src={node.url} />
4545
)}
4646
</div>
4747
))}
@@ -53,14 +53,14 @@ const GatsbyPluginImagePage = ({ data }) => {
5353
<div>
5454
<p>
5555
<strong>
56-
{node.title} ({node.file.fileName.split(".").pop()})
56+
{node.title} ({node.fileName.split(".").pop()})
5757
</strong>
5858
</p>
5959
{node.description && <p>{node.description}</p>}
6060
{node.fixed ? (
6161
<GatsbyImage image={node.fixed} />
6262
) : (
63-
<SvgImage src={node.file.url} />
63+
<SvgImage src={node.url} />
6464
)}
6565
</div>
6666
))}
@@ -72,14 +72,14 @@ const GatsbyPluginImagePage = ({ data }) => {
7272
<div>
7373
<p>
7474
<strong>
75-
{node.title} ({node.file.fileName.split(".").pop()})
75+
{node.title} ({node.fileName.split(".").pop()})
7676
</strong>
7777
</p>
7878
{node.description && <p>{node.description}</p>}
7979
{node.dominantColor ? (
8080
<GatsbyImage image={node.dominantColor} />
8181
) : (
82-
<SvgImage src={node.file.url} />
82+
<SvgImage src={node.url} />
8383
)}
8484
</div>
8585
))}
@@ -91,14 +91,14 @@ const GatsbyPluginImagePage = ({ data }) => {
9191
<div>
9292
<p>
9393
<strong>
94-
{node.title} ({node.file.fileName.split(".").pop()})
94+
{node.title} ({node.fileName.split(".").pop()})
9595
</strong>
9696
</p>
9797
{node.description && <p>{node.description}</p>}
9898
{node.traced ? (
9999
<GatsbyImage image={node.traced} />
100100
) : (
101-
<SvgImage src={node.file.url} />
101+
<SvgImage src={node.url} />
102102
)}
103103
</div>
104104
))}
@@ -110,14 +110,14 @@ const GatsbyPluginImagePage = ({ data }) => {
110110
<div>
111111
<p>
112112
<strong>
113-
{node.title} ({node.file.fileName.split(".").pop()})
113+
{node.title} ({node.fileName.split(".").pop()})
114114
</strong>
115115
</p>
116116
{node.description && <p>{node.description}</p>}
117117
{node.blurred ? (
118118
<GatsbyImage image={node.blurred} />
119119
) : (
120-
<SvgImage src={node.file.url} />
120+
<SvgImage src={node.url} />
121121
)}
122122
</div>
123123
))}
@@ -129,7 +129,7 @@ const GatsbyPluginImagePage = ({ data }) => {
129129
<div>
130130
<p>
131131
<strong>
132-
{node.title} ({node.file.fileName.split(".").pop()})
132+
{node.title} ({node.fileName.split(".").pop()})
133133
</strong>
134134
</p>
135135
{node.description && <p>{node.description}</p>}
@@ -143,7 +143,7 @@ const GatsbyPluginImagePage = ({ data }) => {
143143
}}
144144
/>
145145
) : (
146-
<SvgImage src={node.file.url} />
146+
<SvgImage src={node.url} />
147147
)}
148148
</div>
149149
))}
@@ -173,10 +173,8 @@ export const pageQuery = graphql`
173173
nodes {
174174
title
175175
description
176-
file {
177-
fileName
178-
url
179-
}
176+
fileName
177+
url
180178
constrained: gatsbyImageData(width: 420)
181179
fullWidth: gatsbyImageData(width: 200, layout: FIXED)
182180
fixed: gatsbyImageData(width: 200, layout: FIXED)

0 commit comments

Comments
 (0)