Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Config processors are runtime processors, that change the config of types during the initialization.
There are currently 3 config processors:
public
callback returns falseArgument
object.Although these processor could also be optimized (they don't have to be executed always), this PR is focused on other things.
If we look at any generated type (in the branch
master
), we can see that configs are wrapped into an arrow function:The
webonyx/graphql-php
library doesn't accept closures as config, but arrays. In the code above the$configLoader
is passed toLazyConfig
where it is unwrapped by calling:LazyConfig
is a simple class, that just takes a config closure, unwraps it, applies all 3 processors to it and returns config back as array. I don't know why config is wrapped into a closure, maybe for some historical reasons, because in previous versions it was used to pass$globalVariables
to it, although we could just bind it withuse
:Whatever the reason was, wrapping configs into a closure and passing
$globalVariables
intoLazyConfig
is an unnecessary overhead, therefore the generated classes can look like this:Furthermore the instantiation of the
LazyConfig
object doesn't have to be done inside the type's constructor, but inside the $configProcessor:And after all these changes, if you look at the
LazyConfig
class, you will see that its task could be moved directly intoConfigProcessor
. Therefore theLazyConfig
class is not needed anymore and can be removed.This PR removes the
LazyConfig
class and reduces the number of function calls by type instantiations.Note: don't be confused with the name
LazyConfig
because it doesn't really mean lazy loading