Skip to content
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

❗BREAKING CHANGE❗️Ensure compatibility with graphql-php v15 #953

Merged
merged 32 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1d4eea9
graphql-php-v15: workaround to allow testing with graphql-php v15
mfn Oct 15, 2022
17096de
graphql-php-v15: adding property types due to upstream changes
mfn Oct 15, 2022
5702767
graphql-php-v15: adapt for file/line/trace changes
mfn Oct 17, 2022
bbeb9b1
graphql-php-v15: category as provided by graphql-php has been removed
mfn Oct 17, 2022
e5a5337
graphql-php-v15: add interface to provide errors.*.extensions.categor…
mfn Oct 17, 2022
f5f46c9
graphql-php-v15: use new ProvidesErrorCategory interface on error cla…
mfn Oct 17, 2022
5fcd96a
graphql-php-v15: check for `ProvidesErrorCategory` and add category b…
mfn Oct 17, 2022
c8c61ea
graphql-php-v15: adapt for changed location of debugMessage
mfn Oct 17, 2022
0124fd4
graphql-php-v15: use FCQN now instead only the class name
mfn Oct 17, 2022
363f321
graphql-php-v15: replace `getWrappedType(true)` with `getInnermostTyp…
mfn Oct 17, 2022
da2fde4
graphql-php-v15: adjust for changed error message
mfn Oct 17, 2022
86f2ded
graphql-php-v15: temporarily skip test
mfn Oct 17, 2022
a911604
graphql-php-v15: `OperationParams` methods `getOriginalInput` and `is…
mfn Oct 17, 2022
ebd843a
graphql-php-v15: adapt phpstan config
mfn Oct 17, 2022
c01f88d
graphql-php-v15: adapt phpstan baseline
mfn Oct 17, 2022
38c518d
Revert "graphql-php-v15: temporarily skip test"
mfn Oct 21, 2022
5c702e3
Merge branch 'master' into mp-graphql-php-v15
mfn Jan 7, 2023
5415db9
graphql-php-v15: switch composer version to 15
mfn Jan 7, 2023
9297b5c
graphql-php-v15: fix rename of FieldArgument and arg requires explici…
mfn Jan 7, 2023
5a54bf7
Merge branch 'master' into mp-graphql-php-v15
mfn Jan 7, 2023
027d590
graphql-php-v15: update phpstan baseline
mfn Jan 7, 2023
9f97bf6
graphql-php-v15: composer fix-style
mfn Jan 7, 2023
93632a2
graphql-php-v15: update changelog
mfn Jan 7, 2023
cb78e30
graphql-php-v15: add breaking change headline
mfn Jan 7, 2023
e4530ff
Remove optional support for non-lazy loading of types
mfn Jan 7, 2023
4a93cde
Merge branch 'master' into mp-graphql-php-v15
mfn Jan 13, 2023
0cd9ceb
graphql-php-v15: switch to laragraph/utils release also supporting gr…
mfn Jan 13, 2023
503a966
graphql-php-v15: include a more detailed BC changelog
mfn Jan 13, 2023
88b04d2
Merge branch 'master' into mp-graphql-php-v15
mfn Mar 5, 2023
5e09d34
graphql-php-v15: adapt phpstan after merge with master
mfn Mar 5, 2023
4eb3da7
Merge branch 'master' into mp-graphql-php-v15
mfn Mar 5, 2023
39c5ca9
graphql-php-v15: also resolve our top level types
mfn Mar 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
matrix:
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}
laravel: [^6.0, ^8.0, ^9.0]
lazy_types: ['false', 'true']
exclude:
- php: 7.4
laravel: ^9.0
Expand All @@ -45,7 +44,7 @@ jobs:
laravel: ^6.0
- php: 8.2
laravel: ^6.0
name: P=${{ matrix.php }} L=${{ matrix.laravel }} Lazy types=${{ matrix.lazy_types }}
name: P=${{ matrix.php }} L=${{ matrix.laravel }}
runs-on: ubuntu-latest
env:
COMPOSER_NO_INTERACTION: 1
Expand Down Expand Up @@ -79,9 +78,5 @@ jobs:

- run: composer update --prefer-dist --no-progress

- name: Enable lazy types conditionally
run: echo "TESTS_ENABLE_LAZYLOAD_TYPES=1" >> $GITHUB_ENV
if: matrix.lazy_types == 'true'

- name: Run tests
run: composer tests
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,47 @@ CHANGELOG
[Next release](https://github.com/rebing/graphql-laravel/compare/8.5.0...master)
--------------

## Breaking changes
### Added
- Upgrade to graphql-php 15 [\#953 / mfn](https://github.com/rebing/graphql-laravel/pull/953)\
This includes possible breaking changes also outside of this package, see also https://github.com/webonyx/graphql-php/releases/tag/v15.0.0 \
Known breaking changes:
- non-standard error related data keys are not included directly in
`errors.*.<non-standard error key>` any more, but have been moved to
`errors.*.extensions.<non-standard error key>`.\
Also new keys may appear here from upstream.
- The `errors.*.extensions.category` has been removed upstream, but we try to
keep it alive with the interface
`\Rebing\GraphQL\Error\ProvidesErrorCategory` as it can be a useful
discriminator on the client side in certain cases. But only the cases from
_this_ library are preserved, e.g. categories like `request`, `graphql` or
`internal` are gone.
- The `\Rebing\GraphQL\Support\OperationParams` has added required types due to
its base class changes:
- Old: `public function getOriginalInput($key)`\
new: `public function getOriginalInput(string $key)`
- Old: `public function isReadOnly()`\
new: `public function isReadOnly(): bool`

Some BC may happen also if you extended code originating in graphql-php,
some examples:
- if you implement custom types, you now have to use property types for e.g.
`$name` or `$description`
- If you used any `\GraphQL\Validator\DocumentValidator` in your code
directly, you now need use FQCN to reference them and not the shortened
string names.
- `->getWrappedType(true)` was replaced with `->getInnermostType()`
- the class `\GraphQL\Type\Definition\FieldArgument` has been renamed to
`\GraphQL\Type\Definition\Argument`

### Removed
- Remove support for eager loading (=non-lazy loading) of types\
Lazy loading has been introduced in 2.0.0 (2019-08) and has been made the
default since 8.0.0 (2021-11).\
The practical impact is that types are always going to be resolved using a
type loader and therefore cannot use aliases anymore. Types and their type
name have to match.

2023-01-13, 8.5.0
-----------------
### Added
Expand Down
41 changes: 0 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ The default GraphiQL view makes use of the global `csrf_token()` helper function
- [Upgrading from v1 to v2](#upgrading-from-v1-to-v2)
- [Migrating from Folklore](#migrating-from-folklore)
- [Performance considerations](#performance-considerations)
- [Lazy loading of types](#lazy-loading-of-types)
- [Example of aliasing **not** supported by lazy loading](#example-of-aliasing-not-supported-by-lazy-loading)
- [Wrap Types](#wrap-types)
- [GraphQL testing clients](#graphql-testing-clients)

Expand Down Expand Up @@ -278,12 +276,6 @@ them, in addition to the global middleware. For example:
'default' => [
'query' => [
ExampleQuery::class,
// It's possible to specify a name/alias with the key
// but this is discouraged as it prevents things
// like improving performance with e.g. `lazyload_types=true`
// It's recommended to specify just the class here and
// rely on the `'name'` attribute in the query / type.
'someQuery' => AnotherExampleQuery::class,
],
'mutation' => [
ExampleMutation::class,
Expand Down Expand Up @@ -447,18 +439,6 @@ Alternatively you can:
GraphQL::addType(\App\GraphQL\Types\UserType::class);
```

As with queries/mutations, you can use an alias name (though again this prevents
it from taking advantage of lazy type loading):
```php
'schemas' => [
'default' => [
// ...

'types' => [
'Useralias' => App\GraphQL\Types\UserType::class,
],
```

Then you need to define a query that returns this type (or a list). You can also specify arguments that you can use in the resolve method.
```php
namespace App\GraphQL\Queries;
Expand Down Expand Up @@ -2696,9 +2676,6 @@ To prevent such scenarios, you can add the `UnusedVariablesMiddleware` to your
- `batching`\
- 'enable'\
Whether to support GraphQL batching or not
- `lazyload_types`\
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.
The method should return an array representing the error.
Expand Down Expand Up @@ -2824,24 +2801,6 @@ The following is not a bullet-proof list but should serve as a guide. It's not a

## Performance considerations

### Lazy loading of types

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

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

I.e. you cannot have a query class `ExampleQuery` with the `$name` property
`example` but register it with a different one; this will **not** work:

```php
'query' => [
'aliasedExample' => ExampleQuery::class,
],
```

### Wrap Types

You can wrap types to add more information to the queries and mutations. Similar as the pagination is working you can do the same with your extra data that you want to inject ([see test examples](https://github.com/rebing/graphql-laravel/tree/master/tests/Unit/WithTypeTests)). For instance, in your query:
Expand Down
10 changes: 3 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"ext-json": "*",
"illuminate/contracts": "^6.0|^8.0|^9.0",
"illuminate/support": "^6.0|^8.0|^9.0",
"laragraph/utils": "^1",
"laragraph/utils": "^1.5",
"thecodingmachine/safe": "^1.1|^2.4",
"webonyx/graphql-php": "^14.6.4"
"webonyx/graphql-php": "^15"
},
"require-dev": {
"ext-pdo_sqlite": "*",
Expand Down Expand Up @@ -69,11 +69,7 @@
"phpstan-baseline": "phpstan analyse --memory-limit=512M --generate-baseline",
"lint": "php-cs-fixer fix --diff --dry-run",
"fix-style": "php-cs-fixer fix",
"tests": "phpunit --colors=always --verbose",
"tests-all": [
"TESTS_ENABLE_LAZYLOAD_TYPES=0 phpunit --colors=always --verbose",
"TESTS_ENABLE_LAZYLOAD_TYPES=1 phpunit --colors=always --verbose"
]
"tests": "phpunit --colors=always --verbose"
},
"extra": {
"branch-alias": {
Expand Down
5 changes: 0 additions & 5 deletions config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,6 @@
// \Rebing\GraphQL\Support\UploadType::class,
],

// 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' => true,

// This callable will be passed the Error object for each errors GraphQL catch.
// The method should return an array representing the error.
// Typically:
Expand Down