Skip to content

Commit 882fc09

Browse files
authored
Merge pull request #997 from rebing/mfn-integration-v9
2 parents fb7e341 + 916c8e5 commit 882fc09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+273
-657
lines changed

.github/workflows/integration_tests.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,10 @@ jobs:
3434
fail-fast: false
3535
matrix:
3636
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}
37-
laravel: [^6.0, ^8.0, ^9.0, ^10.0]
37+
laravel: [^8.0, ^9.0, ^10.0]
3838
exclude:
3939
- php: 7.4
4040
laravel: ^9.0
41-
- php: 8.0
42-
laravel: ^6.0
43-
- php: 8.1
44-
laravel: ^6.0
45-
- php: 8.2
46-
laravel: ^6.0
4741
- php: 8.0
4842
laravel: ^10.0
4943
- php: 7.4

.github/workflows/tests.yml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,15 @@ jobs:
3434
fail-fast: false
3535
matrix:
3636
php: ${{ fromJson(needs.supported-versions-matrix.outputs.version) }}
37-
laravel: [^6.0, ^8.0, ^9.0, ^10.0]
38-
lazy_types: ['false', 'true']
37+
laravel: [^8.0, ^9.0, ^10.0]
3938
exclude:
4039
- php: 7.4
4140
laravel: ^9.0
42-
- php: 8.0
43-
laravel: ^6.0
44-
- php: 8.1
45-
laravel: ^6.0
46-
- php: 8.2
47-
laravel: ^6.0
4841
- php: 8.0
4942
laravel: ^10.0
5043
- php: 7.4
5144
laravel: ^10.0
52-
name: P=${{ matrix.php }} L=${{ matrix.laravel }} Lazy types=${{ matrix.lazy_types }}
45+
name: P=${{ matrix.php }} L=${{ matrix.laravel }}
5346
runs-on: ubuntu-latest
5447
env:
5548
COMPOSER_NO_INTERACTION: 1
@@ -83,9 +76,5 @@ jobs:
8376

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

86-
- name: Enable lazy types conditionally
87-
run: echo "TESTS_ENABLE_LAZYLOAD_TYPES=1" >> $GITHUB_ENV
88-
if: matrix.lazy_types == 'true'
89-
9079
- name: Run tests
9180
run: composer tests

CHANGELOG.md

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,57 @@ CHANGELOG
44
[Next release](https://github.com/rebing/graphql-laravel/compare/8.6.0...master)
55
--------------
66

7+
## Breaking changes
8+
### Added
9+
- Upgrade to graphql-php 15 [\#953 / mfn](https://github.com/rebing/graphql-laravel/pull/953)\
10+
This includes possible breaking changes also outside of this package, see also https://github.com/webonyx/graphql-php/releases/tag/v15.0.0 \
11+
Known breaking changes:
12+
- non-standard error related data keys are not included directly in
13+
`errors.*.<non-standard error key>` any more, but have been moved to
14+
`errors.*.extensions.<non-standard error key>`.\
15+
Also new keys may appear here from upstream.
16+
- The `errors.*.extensions.category` has been removed upstream, but we try to
17+
keep it alive with the interface
18+
`\Rebing\GraphQL\Error\ProvidesErrorCategory` as it can be a useful
19+
discriminator on the client side in certain cases. But only the cases from
20+
_this_ library are preserved, e.g. categories like `request`, `graphql` or
21+
`internal` are gone.
22+
- The `\Rebing\GraphQL\Support\OperationParams` has added required types due to
23+
its base class changes:
24+
- Old: `public function getOriginalInput($key)`\
25+
new: `public function getOriginalInput(string $key)`
26+
- Old: `public function isReadOnly()`\
27+
new: `public function isReadOnly(): bool`
28+
29+
Some BC may happen also if you extended code originating in graphql-php,
30+
some examples:
31+
- if you implement custom types, you now have to use property types for e.g.
32+
`$name` or `$description`
33+
- If you used any `\GraphQL\Validator\DocumentValidator` in your code
34+
directly, you now need use FQCN to reference them and not the shortened
35+
string names.
36+
- `->getWrappedType(true)` was replaced with `->getInnermostType()`
37+
- the class `\GraphQL\Type\Definition\FieldArgument` has been renamed to
38+
`\GraphQL\Type\Definition\Argument`
39+
40+
### Removed
41+
- Remove support for eager loading (=non-lazy loading) of types\
42+
Lazy loading has been introduced in 2.0.0 (2019-08) and has been made the
43+
default since 8.0.0 (2021-11).\
44+
The practical impact is that types are always going to be resolved using a
45+
type loader and therefore cannot use aliases anymore. Types and their type
46+
name have to match.
47+
- Remove integrated GraphiQL support in favour of https://github.com/mll-lab/laravel-graphiql [\#986 / mfn](https://github.com/rebing/graphql-laravel/pull/986)
48+
- Laravel 6 is no longer supported [\#967 / mfn](https://github.com/rebing/graphql-laravel/pull/967)
49+
50+
## Changed
51+
- The type resolver is now able to resolve the top level types 'Query',
52+
'Mutation' and 'Subscription'
53+
754
2023-02-18, 8.6.0
855
-----------------
956
### Added
10-
- Add Laravl 10 support [\#983 / jasonvarga](https://github.com/rebing/graphql-laravel/pull/983)
57+
- Add Laravel 10 support [\#983 / jasonvarga](https://github.com/rebing/graphql-laravel/pull/983)
1158

1259
2023-01-13, 8.5.0
1360
-----------------

README.md

Lines changed: 3 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
[![Downloads](https://img.shields.io/packagist/dt/rebing/graphql-laravel.svg?style=flat-square)](https://packagist.org/packages/rebing/graphql-laravel)
77
[![Get on Slack](https://img.shields.io/badge/slack-join-orange.svg)](https://join.slack.com/t/rebing-graphql/shared_invite/enQtNTE5NjQzNDI5MzQ4LTdhNjk0ZGY1N2U1YjE4MGVlYmM2YTc2YjQ0MmIwODY5MWMwZWIwYmY1MWY4NTZjY2Q5MzdmM2Q3NTEyNDYzZjc)
88

9-
Use Facebook's GraphQL with PHP 7.4+ on Laravel 6.0 & 8.0+. It is based on the [PHP port of GraphQL reference implementation](https://github.com/webonyx/graphql-php). You can find more information about GraphQL in the [GraphQL Introduction](https://reactjs.org/blog/2015/05/01/graphql-introduction.html) on the [React](https://reactjs.org/) blog or you can read the [GraphQL specifications](https://spec.graphql.org/).
9+
Use Facebook's GraphQL with PHP 7.4+ on Laravel 8.0+. It is based on the [PHP port of GraphQL reference implementation](https://github.com/webonyx/graphql-php). You can find more information about GraphQL in the [GraphQL Introduction](https://reactjs.org/blog/2015/05/01/graphql-introduction.html) on the [React](https://reactjs.org/) blog or you can read the [GraphQL specifications](https://spec.graphql.org/).
1010

1111
* Allows creating **queries** and **mutations** as request endpoints
1212
* Supports multiple schemas
@@ -56,8 +56,6 @@ Review the configuration file:
5656
config/graphql.php
5757
```
5858

59-
The default GraphiQL view makes use of the global `csrf_token()` helper function.
60-
6159
## Usage
6260

6361
- [Laravel GraphQL](#laravel-graphql)
@@ -69,7 +67,6 @@ The default GraphiQL view makes use of the global `csrf_token()` helper function
6967
- [Concepts](#concepts)
7068
- [A word on declaring a field `nonNull`](#a-word-on-declaring-a-field-nonnull)
7169
- [Data loading](#data-loading)
72-
- [GraphiQL](#graphiql)
7370
- [Middleware Overview](#middleware-overview)
7471
- [HTTP middleware](#http-middleware)
7572
- [GraphQL execution middleware](#graphql-execution-middleware)
@@ -126,8 +123,6 @@ The default GraphiQL view makes use of the global `csrf_token()` helper function
126123
- [Upgrading from v1 to v2](#upgrading-from-v1-to-v2)
127124
- [Migrating from Folklore](#migrating-from-folklore)
128125
- [Performance considerations](#performance-considerations)
129-
- [Lazy loading of types](#lazy-loading-of-types)
130-
- [Example of aliasing **not** supported by lazy loading](#example-of-aliasing-not-supported-by-lazy-loading)
131126
- [Wrap Types](#wrap-types)
132127
- [GraphQL testing clients](#graphql-testing-clients)
133128

@@ -204,20 +199,6 @@ static data, ElasticSearch results, caching, etc.) in your resolvers but you've
204199
to be mindful of the execution model to avoid repetitive fetches and perform
205200
smart pre-fetching of your data.
206201

207-
### GraphiQL
208-
209-
GraphiQL is lightweight "GraphQL IDE" in your browser. It takes advantage of the
210-
GraphQL type system and allows autocompletion of all queries/mutations/types and
211-
fields.
212-
213-
GraphiQL in the meantime evolved in terms of features and complexity, thus for
214-
convenience an older version is directly included with this library.
215-
216-
As enabled by the default configuration, it's available under the `/graphiql`
217-
route.
218-
219-
If you are using multiple schemas, you can access them via `/graphiql/<schema name>`.
220-
221202
### Middleware Overview
222203

223204
The following middleware concepts are supported:
@@ -278,12 +259,6 @@ them, in addition to the global middleware. For example:
278259
'default' => [
279260
'query' => [
280261
ExampleQuery::class,
281-
// It's possible to specify a name/alias with the key
282-
// but this is discouraged as it prevents things
283-
// like improving performance with e.g. `lazyload_types=true`
284-
// It's recommended to specify just the class here and
285-
// rely on the `'name'` attribute in the query / type.
286-
'someQuery' => AnotherExampleQuery::class,
287262
],
288263
'mutation' => [
289264
ExampleMutation::class,
@@ -447,18 +422,6 @@ Alternatively you can:
447422
GraphQL::addType(\App\GraphQL\Types\UserType::class);
448423
```
449424

450-
As with queries/mutations, you can use an alias name (though again this prevents
451-
it from taking advantage of lazy type loading):
452-
```php
453-
'schemas' => [
454-
'default' => [
455-
// ...
456-
457-
'types' => [
458-
'Useralias' => App\GraphQL\Types\UserType::class,
459-
],
460-
```
461-
462425
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.
463426
```php
464427
namespace App\GraphQL\Queries;
@@ -2696,9 +2659,6 @@ To prevent such scenarios, you can add the `UnusedVariablesMiddleware` to your
26962659
- `batching`\
26972660
- 'enable'\
26982661
Whether to support GraphQL batching or not
2699-
- `lazyload_types`\
2700-
The types will be loaded on demand. Enabled by default as it improves
2701-
performance. Cannot be used with type aliasing.
27022662
- `error_formatter`\
27032663
This callable will be passed the Error object for each errors GraphQL catch.
27042664
The method should return an array representing the error.
@@ -2715,19 +2675,6 @@ To prevent such scenarios, you can add the `UnusedVariablesMiddleware` to your
27152675
You can define your own pagination type.
27162676
- `simple_pagination_type`\
27172677
You can define your own simple pagination type.
2718-
- `graphiql`\
2719-
Config for GraphiQL (see (https://github.com/graphql/graphiql)
2720-
- `prefix`\
2721-
The route prefix
2722-
- `controller`\
2723-
The controller / method to handle the route
2724-
- `middleware`\
2725-
Any middleware to be run before invoking the controller
2726-
- `view`\
2727-
Which view to use
2728-
- `display`\
2729-
Whether to enable it or not.\
2730-
**Note:** it's recommended to disable this in production!
27312678
- `defaultFieldResolver`\
27322679
Overrides the default field resolver, see http://webonyx.github.io/graphql-php/data-fetching/#default-field-resolver
27332680
- `headers`\
@@ -2809,7 +2756,7 @@ The following is not a bullet-proof list but should serve as a guide. It's not a
28092756
- `composer remove folklore/graphql`
28102757
- if you've a custom ServiceProvider or did include it manually, remove it. The point is that the existing GraphQL code should not be triggered to run.
28112758
- `composer require rebing/graphql-laravel`
2812-
- Publish `config/graphql.php` and adapt it (prefix, middleware, schemas, types, mutations, queries, security settings, graphiql)
2759+
- Publish `config/graphql.php` and adapt it (prefix, middleware, schemas, types, mutations, queries, security settings)
28132760
- Removed settings
28142761
- `domain`
28152762
- `resolvers`
@@ -2824,24 +2771,6 @@ The following is not a bullet-proof list but should serve as a guide. It's not a
28242771

28252772
## Performance considerations
28262773

2827-
### Lazy loading of types
2828-
2829-
Lazy loading of types is a way of improving the start up performance.
2830-
2831-
If you are declaring types using aliases, this is not supported and you need to
2832-
set `lazyload_types` set to `false`.
2833-
2834-
#### Example of aliasing **not** supported by lazy loading
2835-
2836-
I.e. you cannot have a query class `ExampleQuery` with the `$name` property
2837-
`example` but register it with a different one; this will **not** work:
2838-
2839-
```php
2840-
'query' => [
2841-
'aliasedExample' => ExampleQuery::class,
2842-
],
2843-
```
2844-
28452774
### Wrap Types
28462775

28472776
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:
@@ -2870,4 +2799,4 @@ public function resolve($root, array $args)
28702799

28712800
## GraphQL testing clients
28722801
- [Firecamp](https://firecamp.io/graphql)
2873-
- [GraphiQL](https://github.com/graphql/graphiql)
2802+
- [GraphiQL](https://github.com/graphql/graphiql) [integration via laravel-graphiql](https://github.com/mll-lab/laravel-graphiql)

composer.json

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
"require": {
3737
"php": ">= 7.4",
3838
"ext-json": "*",
39-
"illuminate/contracts": "^6.0|^8.0|^9.0|^10.0",
40-
"illuminate/support": "^6.0|^8.0|^9.0|^10.0",
41-
"laragraph/utils": "^1",
39+
"illuminate/contracts": "^8.0|^9.0|^10.0",
40+
"illuminate/support": "^8.0|^9.0|^10.0",
41+
"laragraph/utils": "^1.5",
4242
"thecodingmachine/safe": "^1.1|^2.4",
43-
"webonyx/graphql-php": "^14.6.4"
43+
"webonyx/graphql-php": "^15"
4444
},
4545
"require-dev": {
4646
"ext-pdo_sqlite": "*",
@@ -50,8 +50,8 @@
5050
"mockery/mockery": "^1.2",
5151
"phpstan/phpstan": "1.10.3",
5252
"nunomaduro/larastan": "2.4.1",
53-
"orchestra/testbench": "4.0.*|5.0.*|^6.0|^7.0|^8.0",
54-
"phpunit/phpunit": "~7.0|~8.0|^9",
53+
"orchestra/testbench": "^6.0|^7.0|^8.0",
54+
"phpunit/phpunit": "~8.0|^9",
5555
"thecodingmachine/phpstan-safe-rule": "^1"
5656
},
5757
"autoload": {
@@ -69,11 +69,7 @@
6969
"phpstan-baseline": "phpstan analyse --memory-limit=512M --generate-baseline",
7070
"lint": "php-cs-fixer fix --diff --dry-run",
7171
"fix-style": "php-cs-fixer fix",
72-
"tests": "phpunit --colors=always --verbose",
73-
"tests-all": [
74-
"TESTS_ENABLE_LAZYLOAD_TYPES=0 phpunit --colors=always --verbose",
75-
"TESTS_ENABLE_LAZYLOAD_TYPES=1 phpunit --colors=always --verbose"
76-
]
72+
"tests": "phpunit --colors=always --verbose"
7773
},
7874
"extra": {
7975
"branch-alias": {
@@ -93,5 +89,8 @@
9389
"config": {
9490
"preferred-install": "dist",
9591
"sort-packages": true
92+
},
93+
"suggest": {
94+
"mll-lab/laravel-graphiql": "Easily integrate GraphiQL into your Laravel projects. "
9695
}
9796
}

config/config.php

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@
111111
// \Rebing\GraphQL\Support\UploadType::class,
112112
],
113113

114-
// The types will be loaded on demand. Default is to load all types on each request
115-
// Can increase performance on schemes with many types
116-
// Presupposes the config type key to match the type class name property
117-
'lazyload_types' => true,
118-
119114
// This callable will be passed the Error object for each errors GraphQL catch.
120115
// The method should return an array representing the error.
121116
// Typically:
@@ -157,17 +152,6 @@
157152
*/
158153
'simple_pagination_type' => \Rebing\GraphQL\Support\SimplePaginationType::class,
159154

160-
/*
161-
* Config for GraphiQL (see (https://github.com/graphql/graphiql).
162-
*/
163-
'graphiql' => [
164-
'prefix' => 'graphiql', // Do NOT use a leading slash
165-
'controller' => \Rebing\GraphQL\GraphQLController::class . '@graphiql',
166-
'middleware' => [],
167-
'view' => 'graphql::graphiql',
168-
'display' => env('ENABLE_GRAPHIQL', true),
169-
],
170-
171155
/*
172156
* Overrides the default field resolver
173157
* See http://webonyx.github.io/graphql-php/data-fetching/#default-field-resolver

0 commit comments

Comments
 (0)