Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: out-of-memory crash (#7720) and significantly improve performance + feat: extracting fields to types #9705

Merged
merged 2 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/hip-garlics-invent.md
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
}
}
}
`;
Loading
Loading