Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ CHANGELOG
- Add ability to detect unused GraphQL variables [\#660 / mfn](https://github.com/rebing/graphql-laravel/pull/660)
- Laravels `ValidationException` is now formatted the same way as a `ValidationError` [\#748 / mfn](https://github.com/rebing/graphql-laravel/pull/748)

### Changed
- Lazy loading types has been enabled by default [\#758 / mfn](https://github.com/rebing/graphql-laravel/pull/758)

2021-04-10, 7.2.0
-----------------
### Added
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2616,7 +2616,7 @@ and set it to `true`.
- 'enable'\
Whether to support GraphQL batching or not
- `lazyload_types`\
The types will be loaded on demand. Recommended being enabled as it improves
The types will be loaded on demand. Enabled by default as it improves
performance. Cannot be used with type aliasing.
- `error_formatter`\
This callable will be passed the Error object for each errors GraphQL catch.
Expand Down Expand Up @@ -2747,8 +2747,8 @@ The following is not a bullet-proof list but should serve as a guide. It's not a

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
// The types will be loaded on demand. Default is to load all types on each request
// Can increase performance on schemes with many types
// Presupposes the config type key to match the type class name property
'lazyload_types' => false,
'lazyload_types' => true,

// This callable will be passed the Error object for each errors GraphQL catch.
// The method should return an array representing the error.
Expand Down
4 changes: 2 additions & 2 deletions src/GraphQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function schema($schema = null): Schema

return $types;
},
'typeLoader' => config('graphql.lazyload_types', false)
'typeLoader' => config('graphql.lazyload_types', true)
? function ($name) {
return $this->type($name);
}
Expand Down Expand Up @@ -207,7 +207,7 @@ public function getType(string $name, bool $fresh = false): Type
if (!isset($this->types[$name])) {
$error = "Type $name not found.";

if (config('graphql.lazyload_types', false)) {
if (config('graphql.lazyload_types', true)) {
$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";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ protected function getEnvironmentSetUp($app): void
{
parent::getEnvironmentSetUp($app);

$app['config']->set('graphql.lazyload_types', false);

$app['config']->set('graphql.schemas.default', [
'query' => [
PrimaryKeyQuery::class,
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ protected function setUp(): void

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

$app['config']->set('graphql.schemas.default', [
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/TypesInSchemas/TypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ protected function getEnvironmentSetUp($app): void
// Note: deliberately not calling parent to start with a clean config

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

Expand Down