Skip to content

Commit

Permalink
Move object initalisation behind a feature toggle (#210)
Browse files Browse the repository at this point in the history
Moved the initialisation of __internalShouldIncludePath under field node
to happen behind the configuration option
compilationContext.options.useExperimentalPathBasedSkipInclude.

The context for the change is that updating from 0.8.0 to 0.8.2 has
shown increased Garbage Collector rates in use cases with big queries,
and this change could be used to verify the hypothesis whether the
initialisation of __internalShouldIncludePath is a cause for the GC
runs.
  • Loading branch information
oporkka committed Jun 29, 2023
1 parent 460daa4 commit efa15a4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,6 @@ function collectFieldsImpl(
selection
);

if (!fieldNode.__internalShouldIncludePath)
fieldNode.__internalShouldIncludePath = {};

/**
* Carry over fragment's skip and include code
*
Expand All @@ -143,6 +140,9 @@ function collectFieldsImpl(
* `should include`s generated for the current fieldNode
*/
if (compilationContext.options.useExperimentalPathBasedSkipInclude) {
if (!fieldNode.__internalShouldIncludePath)
fieldNode.__internalShouldIncludePath = {};

fieldNode.__internalShouldIncludePath[currentPath] =
joinShouldIncludeCompilations(
fieldNode.__internalShouldIncludePath?.[currentPath] ?? "",
Expand Down Expand Up @@ -326,10 +326,10 @@ function augmentFieldNodeTree(
);

if (!comesFromFragmentSpread) {
if (!jitFieldNode.__internalShouldIncludePath)
jitFieldNode.__internalShouldIncludePath = {};

if (compilationContext.options.useExperimentalPathBasedSkipInclude) {
if (!jitFieldNode.__internalShouldIncludePath)
jitFieldNode.__internalShouldIncludePath = {};

jitFieldNode.__internalShouldIncludePath[currentPath] =
joinShouldIncludeCompilations(
parentFieldNode.__internalShouldIncludePath?.[
Expand Down

0 comments on commit efa15a4

Please sign in to comment.