-
-
Notifications
You must be signed in to change notification settings - Fork 565
Lazy loading for arguments #429
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ composer.lock | |
composer.phar | ||
phpcs.xml | ||
phpstan.neon | ||
vendor/ | ||
vendor/ | ||
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ | |||||
use GraphQL\Language\AST\InputValueDefinitionNode; | ||||||
use GraphQL\Utils\Utils; | ||||||
use function is_array; | ||||||
use function is_callable; | ||||||
use function is_string; | ||||||
use function sprintf; | ||||||
|
||||||
|
@@ -66,12 +67,21 @@ public function __construct(array $def) | |||||
} | ||||||
|
||||||
/** | ||||||
* @param mixed[] $config | ||||||
* @param mixed[]|callable $config | ||||||
* | ||||||
* @return FieldArgument[] | ||||||
* @throws \InvalidArgumentException | ||||||
*/ | ||||||
public static function createMap(array $config) | ||||||
public static function createMap($config) | ||||||
{ | ||||||
if (is_callable($config)) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry for the long delay, but as promised I tried out your changes. So far I don't quite understand how this changes things; I tested this by converting a few of the What am I missing, here? Where does the "lazy" happen? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just POC'ed my own full lazy loading concept; so far seems to work pretty well. I'll try to put together a PR by the end of the week. |
||||||
$config = $config(); | ||||||
} | ||||||
|
||||||
if (! is_array($config)) { | ||||||
throw new \InvalidArgumentException('$config must be an array or a callable which returns such an array.'); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
$map = []; | ||||||
foreach ($config as $name => $argConfig) { | ||||||
if (! is_array($argConfig)) { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're missing a line feed
If you're using Jetbrains IDE, it can be automatically handled by
Editor -> General -> Other