Skip to content

Commit c43752d

Browse files
authored
Merge pull request #758 from rebing/mfn-lazy-types
Enable lazyload_types by default
2 parents 26302c1 + 1a7d5d7 commit c43752d

File tree

7 files changed

+13
-12
lines changed

7 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ CHANGELOG
9292
- Add ability to detect unused GraphQL variables [\#660 / mfn](https://github.com/rebing/graphql-laravel/pull/660)
9393
- Laravels `ValidationException` is now formatted the same way as a `ValidationError` [\#748 / mfn](https://github.com/rebing/graphql-laravel/pull/748)
9494

95+
### Changed
96+
- Lazy loading types has been enabled by default [\#758 / mfn](https://github.com/rebing/graphql-laravel/pull/758)
97+
9598
2021-04-10, 7.2.0
9699
-----------------
97100
### Added

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2616,7 +2616,7 @@ and set it to `true`.
26162616
- 'enable'\
26172617
Whether to support GraphQL batching or not
26182618
- `lazyload_types`\
2619-
The types will be loaded on demand. Recommended being enabled as it improves
2619+
The types will be loaded on demand. Enabled by default as it improves
26202620
performance. Cannot be used with type aliasing.
26212621
- `error_formatter`\
26222622
This callable will be passed the Error object for each errors GraphQL catch.
@@ -2747,8 +2747,8 @@ The following is not a bullet-proof list but should serve as a guide. It's not a
27472747

27482748
Lazy loading of types is a way of improving the start up performance.
27492749

2750-
If you are declaring types using aliases it is not supported.
2751-
If that is not the case, you can enable it with `lazyload_types` set to `true`.
2750+
If you are declaring types using aliases, this is not supported and you need to
2751+
set `lazyload_types` set to `false`.
27522752

27532753
#### Example of aliasing **not** supported by lazy loading
27542754

config/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
// The types will be loaded on demand. Default is to load all types on each request
107107
// Can increase performance on schemes with many types
108108
// Presupposes the config type key to match the type class name property
109-
'lazyload_types' => false,
109+
'lazyload_types' => true,
110110

111111
// This callable will be passed the Error object for each errors GraphQL catch.
112112
// The method should return an array representing the error.

src/GraphQL.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function schema($schema = null): Schema
103103

104104
return $types;
105105
},
106-
'typeLoader' => config('graphql.lazyload_types', false)
106+
'typeLoader' => config('graphql.lazyload_types', true)
107107
? function ($name) {
108108
return $this->type($name);
109109
}
@@ -207,7 +207,7 @@ public function getType(string $name, bool $fresh = false): Type
207207
if (!isset($this->types[$name])) {
208208
$error = "Type $name not found.";
209209

210-
if (config('graphql.lazyload_types', false)) {
210+
if (config('graphql.lazyload_types', true)) {
211211
$error .= "\nCheck that the config array key for the type matches the name attribute in the type's class.\nIt is required when 'lazyload_types' is enabled";
212212
}
213213

tests/Database/SelectFields/PrimaryKeyTests/PrimaryKeyTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ protected function getEnvironmentSetUp($app): void
1616
{
1717
parent::getEnvironmentSetUp($app);
1818

19-
$app['config']->set('graphql.lazyload_types', false);
20-
2119
$app['config']->set('graphql.schemas.default', [
2220
'query' => [
2321
PrimaryKeyQuery::class,

tests/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ protected function setUp(): void
4242

4343
protected function getEnvironmentSetUp($app): void
4444
{
45-
if ('1' === env('TESTS_ENABLE_LAZYLOAD_TYPES')) {
46-
$app['config']->set('graphql.lazyload_types', true);
45+
if ('0' === env('TESTS_ENABLE_LAZYLOAD_TYPES')) {
46+
$app['config']->set('graphql.lazyload_types', false);
4747
}
4848

4949
$app['config']->set('graphql.schemas.default', [

tests/Unit/TypesInSchemas/TypesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ protected function getEnvironmentSetUp($app): void
1212
// Note: deliberately not calling parent to start with a clean config
1313

1414
// To still properly support dual tests, we thus have to add this
15-
if ('1' === env('TESTS_ENABLE_LAZYLOAD_TYPES')) {
16-
$app['config']->set('graphql.lazyload_types', true);
15+
if ('0' === env('TESTS_ENABLE_LAZYLOAD_TYPES')) {
16+
$app['config']->set('graphql.lazyload_types', false);
1717
}
1818
}
1919

0 commit comments

Comments
 (0)