Skip to content

Commit 1bed87b

Browse files
bbrzoskaniieani
andauthored
fix: out-of-memory crash (#7720) and significantly improve performance + feat: extracting fields to types (#9705)
* fix: out-of-memory crash and significantly improve performance Co-authored-by: Cynthia Ma <cma@zendesk.com> Co-authored-by: Bazyli Brzoska <bbrzoska@zendesk.com> fixes #7720 * test: add bug reproduction from #7720 fixes #7720 --------- Co-authored-by: Bazyli Brzóska <bazyli.brzoska@gmail.com>
1 parent 8a4743f commit 1bed87b

File tree

13 files changed

+24334
-106
lines changed

13 files changed

+24334
-106
lines changed

.changeset/hip-garlics-invent.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@graphql-codegen/visitor-plugin-common': minor
3+
'@graphql-codegen/typescript-operations': minor
4+
---
5+
6+
fix: out-of-memory crash (fixes #7720)
7+
perf: implement a caching mechanism that makes sure the type originating at the same location is never generated twice, as long as the combination of selected fields and possible types matches
8+
feat: implement `extractAllFieldsToTypes: boolean`
9+
feat: implement `printFieldsOnNewLines: boolean`

dev-test/gatsby/fragments.ts

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
import gql from 'graphql-tag';
2+
3+
export const WPColumns = gql`
4+
fragment WPColumns on WpCoreColumnsBlock {
5+
__typename
6+
attributes {
7+
... on WpCoreColumnsBlockAttributes {
8+
align
9+
verticalAlignment
10+
}
11+
}
12+
innerBlocks {
13+
...WpColumnFields
14+
...WpCoreImageBlockFragment
15+
...WpCoreGalleryBlockFragment
16+
innerBlocks {
17+
__typename
18+
...WpCoreImageBlockForGalleryFragment
19+
...WpCoreGalleryBlockFragment
20+
saveContent
21+
dynamicContent
22+
isDynamic
23+
#
24+
... on WpCoreGalleryBlock {
25+
__typename
26+
...WpCoreGalleryBlockFragment
27+
28+
innerBlocks {
29+
__typename
30+
...WpCoreImageBlockForGalleryFragment
31+
}
32+
}
33+
... on WpCoreColumnsBlock {
34+
innerBlocks {
35+
...WpColumnFields
36+
innerBlocks {
37+
...WpCoreImageBlockFragment
38+
...WpCoreGalleryBlockFragment
39+
... on WpCoreColumnsBlock {
40+
innerBlocks {
41+
...WpColumnFields
42+
innerBlocks {
43+
...WpCoreImageBlockForGalleryFragment
44+
...WpCoreGalleryBlockFragment
45+
}
46+
}
47+
}
48+
}
49+
}
50+
}
51+
}
52+
}
53+
}
54+
`;
55+
56+
export const wpColumnFields = gql`
57+
fragment WpColumnFields on WpCoreColumnBlock {
58+
__typename
59+
saveContent
60+
dynamicContent
61+
isDynamic
62+
attributes {
63+
__typename
64+
}
65+
}
66+
`;
67+
68+
export const WpCoreImageBlockFragment = gql`
69+
fragment WpCoreImageBlockFragment on WpCoreImageBlock {
70+
__typename
71+
saveContent
72+
originalContent
73+
attributes {
74+
__typename
75+
... on WpCoreImageBlockAttributes {
76+
id
77+
alt
78+
caption
79+
width
80+
title
81+
height
82+
linkTarget
83+
url
84+
imageFluid {
85+
childImageSharp {
86+
gatsbyImageData(quality: 100, layout: FULL_WIDTH)
87+
}
88+
}
89+
}
90+
}
91+
}
92+
`;
93+
94+
export const WpCoreImageBlockForGalleryFragment = gql`
95+
fragment WpCoreImageBlockForGalleryFragment on WpCoreImageBlock {
96+
__typename
97+
saveContent
98+
attributes {
99+
__typename
100+
... on WpCoreImageBlockAttributes {
101+
id
102+
alt
103+
caption
104+
width
105+
title
106+
height
107+
linkTarget
108+
url
109+
imageFluid {
110+
childImageSharp {
111+
full: gatsbyImageData(quality: 100, layout: FULL_WIDTH)
112+
thumbnail: gatsbyImageData(layout: CONSTRAINED)
113+
}
114+
}
115+
}
116+
}
117+
}
118+
`;
119+
120+
export const WpCoreParagraphBlockFragment = gql`
121+
fragment WpCoreParagraphBlockFragment on WpCoreParagraphBlock {
122+
__typename
123+
saveContent
124+
isDynamic
125+
dynamicContent
126+
}
127+
`;
128+
129+
export const WpCoreGalleryBlockFragment = gql`
130+
fragment WpCoreGalleryBlockFragment on WpCoreGalleryBlock {
131+
dynamicContent
132+
attributes {
133+
... on WpCoreGalleryBlockAttributes {
134+
align
135+
anchor
136+
ids
137+
caption
138+
images {
139+
id
140+
url
141+
link
142+
alt
143+
caption
144+
}
145+
className
146+
}
147+
}
148+
}
149+
`;

0 commit comments

Comments
 (0)