Skip to content

Commit

Permalink
fix: out-of-memory crash (#7720) and significantly improve performanc…
Browse files Browse the repository at this point in the history
…e + 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>
  • Loading branch information
bbrzoska and niieani committed Oct 26, 2023
1 parent 8a4743f commit 1bed87b
Show file tree
Hide file tree
Showing 13 changed files with 24,334 additions and 106 deletions.
9 changes: 9 additions & 0 deletions .changeset/hip-garlics-invent.md
@@ -0,0 +1,9 @@
---
'@graphql-codegen/visitor-plugin-common': minor
'@graphql-codegen/typescript-operations': minor
---

fix: out-of-memory crash (fixes #7720)
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
feat: implement `extractAllFieldsToTypes: boolean`
feat: implement `printFieldsOnNewLines: boolean`
149 changes: 149 additions & 0 deletions dev-test/gatsby/fragments.ts
@@ -0,0 +1,149 @@
import gql from 'graphql-tag';

export const WPColumns = gql`
fragment WPColumns on WpCoreColumnsBlock {
__typename
attributes {
... on WpCoreColumnsBlockAttributes {
align
verticalAlignment
}
}
innerBlocks {
...WpColumnFields
...WpCoreImageBlockFragment
...WpCoreGalleryBlockFragment
innerBlocks {
__typename
...WpCoreImageBlockForGalleryFragment
...WpCoreGalleryBlockFragment
saveContent
dynamicContent
isDynamic
#
... on WpCoreGalleryBlock {
__typename
...WpCoreGalleryBlockFragment
innerBlocks {
__typename
...WpCoreImageBlockForGalleryFragment
}
}
... on WpCoreColumnsBlock {
innerBlocks {
...WpColumnFields
innerBlocks {
...WpCoreImageBlockFragment
...WpCoreGalleryBlockFragment
... on WpCoreColumnsBlock {
innerBlocks {
...WpColumnFields
innerBlocks {
...WpCoreImageBlockForGalleryFragment
...WpCoreGalleryBlockFragment
}
}
}
}
}
}
}
}
}
`;

export const wpColumnFields = gql`
fragment WpColumnFields on WpCoreColumnBlock {
__typename
saveContent
dynamicContent
isDynamic
attributes {
__typename
}
}
`;

export const WpCoreImageBlockFragment = gql`
fragment WpCoreImageBlockFragment on WpCoreImageBlock {
__typename
saveContent
originalContent
attributes {
__typename
... on WpCoreImageBlockAttributes {
id
alt
caption
width
title
height
linkTarget
url
imageFluid {
childImageSharp {
gatsbyImageData(quality: 100, layout: FULL_WIDTH)
}
}
}
}
}
`;

export const WpCoreImageBlockForGalleryFragment = gql`
fragment WpCoreImageBlockForGalleryFragment on WpCoreImageBlock {
__typename
saveContent
attributes {
__typename
... on WpCoreImageBlockAttributes {
id
alt
caption
width
title
height
linkTarget
url
imageFluid {
childImageSharp {
full: gatsbyImageData(quality: 100, layout: FULL_WIDTH)
thumbnail: gatsbyImageData(layout: CONSTRAINED)
}
}
}
}
}
`;

export const WpCoreParagraphBlockFragment = gql`
fragment WpCoreParagraphBlockFragment on WpCoreParagraphBlock {
__typename
saveContent
isDynamic
dynamicContent
}
`;

export const WpCoreGalleryBlockFragment = gql`
fragment WpCoreGalleryBlockFragment on WpCoreGalleryBlock {
dynamicContent
attributes {
... on WpCoreGalleryBlockAttributes {
align
anchor
ids
caption
images {
id
url
link
alt
caption
}
className
}
}
}
`;

0 comments on commit 1bed87b

Please sign in to comment.