Skip to content

Commit 118681d

Browse files
committed
refactor: flatten Contentful asset data structure to match GraphQL API schema (#31115)
1 parent 4245c76 commit 118681d

File tree

11 files changed

+640
-1246
lines changed

11 files changed

+640
-1246
lines changed

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

Lines changed: 20 additions & 26 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
))}
@@ -116,14 +116,14 @@ const GatsbyImagePage = ({ data }) => {
116116
<div>
117117
<p>
118118
<strong>
119-
{node.title} ({node.file.fileName.split(".").pop()})
119+
{node.title} ({node.fileName.split(".").pop()})
120120
</strong>
121121
</p>
122122
{node.description && <p>{node.description}</p>}
123123
{node.fluid ? (
124124
<GatsbyImage fluid={node.fluid} />
125125
) : (
126-
<SvgImage src={node.file.url} />
126+
<SvgImage src={node.url} />
127127
)}
128128
</div>
129129
))}
@@ -135,14 +135,14 @@ const GatsbyImagePage = ({ data }) => {
135135
<div>
136136
<p>
137137
<strong>
138-
{node.title} ({node.file.fileName.split(".").pop()})
138+
{node.title} ({node.fileName.split(".").pop()})
139139
</strong>
140140
</p>
141141
{node.description && <p>{node.description}</p>}
142142
{node.fluid ? (
143143
<GatsbyImage fluid={node.fluid} />
144144
) : (
145-
<SvgImage src={node.file.url} />
145+
<SvgImage src={node.url} />
146146
)}
147147
</div>
148148
))}
@@ -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
fluid(maxWidth: 420) {
181179
...GatsbyContentfulFluid
182180
}
@@ -203,10 +201,8 @@ export const pageQuery = graphql`
203201
nodes {
204202
title
205203
description
206-
file {
207-
fileName
208-
url
209-
}
204+
fileName
205+
url
210206
fluid(maxWidth: 420) {
211207
...GatsbyContentfulFluid
212208
}
@@ -221,10 +217,8 @@ export const pageQuery = graphql`
221217
nodes {
222218
title
223219
description
224-
file {
225-
fileName
226-
url
227-
}
220+
fileName
221+
url
228222
fluid(maxWidth: 420) {
229223
...GatsbyContentfulFluid
230224
}

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

Lines changed: 24 additions & 30 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
))}
@@ -155,14 +155,14 @@ const GatsbyPluginImagePage = ({ data }) => {
155155
<div>
156156
<p>
157157
<strong>
158-
{node.title} ({node.file.fileName.split(".").pop()})
158+
{node.title} ({node.fileName.split(".").pop()})
159159
</strong>
160160
</p>
161161
{node.description && <p>{node.description}</p>}
162162
{node.constrained ? (
163163
<GatsbyImage image={node.constrained} />
164164
) : (
165-
<SvgImage src={node.file.url} />
165+
<SvgImage src={node.url} />
166166
)}
167167
</div>
168168
))}
@@ -174,14 +174,14 @@ const GatsbyPluginImagePage = ({ data }) => {
174174
<div>
175175
<p>
176176
<strong>
177-
{node.title} ({node.file.fileName.split(".").pop()})
177+
{node.title} ({node.fileName.split(".").pop()})
178178
</strong>
179179
</p>
180180
{node.description && <p>{node.description}</p>}
181181
{node.constrained ? (
182182
<GatsbyImage image={node.constrained} />
183183
) : (
184-
<SvgImage src={node.file.url} />
184+
<SvgImage src={node.url} />
185185
)}
186186
</div>
187187
))}
@@ -212,10 +212,8 @@ export const pageQuery = graphql`
212212
nodes {
213213
title
214214
description
215-
file {
216-
fileName
217-
url
218-
}
215+
fileName
216+
url
219217
constrained: gatsbyImageData(width: 420)
220218
fullWidth: gatsbyImageData(width: 200, layout: FIXED)
221219
fixed: gatsbyImageData(width: 200, layout: FIXED)
@@ -248,10 +246,8 @@ export const pageQuery = graphql`
248246
nodes {
249247
title
250248
description
251-
file {
252-
fileName
253-
url
254-
}
249+
fileName
250+
url
255251
constrained: gatsbyImageData(width: 420)
256252
}
257253
}
@@ -264,10 +260,8 @@ export const pageQuery = graphql`
264260
nodes {
265261
title
266262
description
267-
file {
268-
fileName
269-
url
270-
}
263+
fileName
264+
url
271265
constrained: gatsbyImageData(width: 420)
272266
}
273267
}

0 commit comments

Comments
 (0)