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(gql): inifite loop with circular references [] #383

Closed
wants to merge 3 commits into from

Conversation

chrishelgert
Copy link
Contributor

@chrishelgert chrishelgert commented Oct 26, 2023

  • Use the depth limit for GraphQL if no gqlParams have been provided, to prevent an endless loop of updates for circular references
  • Drop VisitedReferencesMap and EntityReferenceMap in favor of the EditorEntityStore
  • Move the store up on a higher level to be better accessible and increase update speed
  • Move the depth handling the other way around, instead of increase the depth, decrease the remaining depth
  • Additionally define a custom depth for rich text (only two levels instead of max 10)

@chrishelgert chrishelgert force-pushed the fix/gql-infinite-loop branch from cdf90d1 to a7ec530 Compare October 26, 2023 15:06
@chrishelgert chrishelgert force-pushed the fix/gql-infinite-loop branch from a7ec530 to 8e3daba Compare October 27, 2023 07:58
@chrishelgert chrishelgert marked this pull request as ready for review October 27, 2023 07:59
@chrishelgert chrishelgert requested review from YvesRijckaert, aodhagan-cf and a team October 27, 2023 08:00
@chrishelgert chrishelgert force-pushed the fix/gql-infinite-loop branch 2 times, most recently from c6fe18f to f766be8 Compare October 27, 2023 09:09
return maxDepth >= 0;
}

function getRichTextDepth(maxDepth: number) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return Math.min(maxDepth - 1, MAX_RTE_DEPTH); does this do the same?

@chrishelgert chrishelgert force-pushed the fix/gql-infinite-loop branch from f766be8 to a73451d Compare October 27, 2023 11:19
depth: number,
visitedReferenceMap: Map<string, Reference>,
sendMessage: SendMessage
maxDepth: number,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why have you changed this from depth to maxDepth sorry I think I'm missing this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we can define a different maxDepth for RichText

it's easier in this one, as we otherwise would need to start with 8 for rich text and check for the limit of 10

@@ -9,6 +9,7 @@ export const TOOLTIP_HEIGHT = 32;
export const TOOLTIP_PADDING_LEFT = 5;

export const MAX_DEPTH = 10;
export const MAX_RTE_DEPTH = 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why we need 2 for rich text?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 Level depth for the direct references
Assuming it's an entry it could be relevant to resolve also the asset of this entry, therefore then 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants