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

Add Laravel 7 support #597

Merged
merged 13 commits into from
Mar 7, 2020
Merged
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
13 changes: 9 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -24,24 +24,26 @@ matrix:
- php: '7.2'
env: LARAVEL='^6.0'
- php: '7.2'
env: LARAVEL='dev-master'
env: LARAVEL='^7.0'
- php: '7.3'
env: LARAVEL='5.5.*'
- php: '7.3'
env: LARAVEL='5.8.*'
- php: '7.3'
env: LARAVEL='^6.0' INSTALL_LARAVEL=1 INSTALL_LUMEN=1
env: LARAVEL='^6.0'
- php: '7.3'
env: LARAVEL='^7.0' INSTALL_LARAVEL=1 INSTALL_LUMEN=1
- php: '7.3'
env: LARAVEL='dev-master'
- php: '7.4'
env: LARAVEL='5.8.*'
- php: '7.4'
env: LARAVEL='^6.0'
- php: '7.4'
env: LARAVEL='^7.0'
- php: '7.4'
env: LARAVEL='dev-master'
allow_failures:
- php: '7.2'
env: LARAVEL='dev-master'
- php: '7.3'
env: LARAVEL='dev-master'
- php: '7.4'
@@ -60,6 +62,9 @@ install:
if [[ $LARAVEL = '^6.0' ]]; then
composer require "illuminate/contracts:${LARAVEL}" --no-interaction --no-update
fi
if [[ $LARAVEL = '^7.0' ]]; then
composer require "illuminate/contracts:${LARAVEL}" --no-interaction --no-update
fi
# dev-master requires liftig other requirements too
if [[ $LARAVEL = 'dev-master' ]]; then
composer require "illuminate/contracts:${LARAVEL}" --no-interaction --no-update
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ CHANGELOG
--------------

### Added
- Support Laravel 7 [\#597 / exodusanto](https://github.com/rebing/graphql-laravel/pull/597)
- Add support for custom authorization message [\#578 / Sh1d0w](https://github.com/rebing/graphql-laravel/pull/578)
- Add support for macros on the GraphQL service/facade [\#592 / stevelacey](https://github.com/rebing/graphql-laravel/pull/592)
### Fixed
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -34,13 +34,13 @@
"type": "project",
"require": {
"php": ">= 7.1",
"illuminate/contracts": "5.5.*|5.6.*|5.7.*|5.8.*|^6.0",
"illuminate/support": "5.5.*|5.6.*|5.7.*|5.8.*|^6.0",
"illuminate/contracts": "5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0",
"illuminate/support": "5.5.*|5.6.*|5.7.*|5.8.*|^6.0|^7.0",
"webonyx/graphql-php": "^0.13",
"ext-json": "*"
},
"require-dev": {
"orchestra/testbench": "3.5.*|3.6.*|3.7.*|3.8.*|3.9.*|4.0.*",
"orchestra/testbench": "3.5.*|3.6.*|3.7.*|3.8.*|3.9.*|4.0.*|5.0.*",
"phpunit/phpunit": "^5.5|~6.0|~7.0|~8.0",
"nunomaduro/larastan": "0.5.0",
"mockery/mockery": "^1.2",
2 changes: 2 additions & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -44,4 +44,6 @@ parameters:
- '/Trying to invoke Closure\|null but it might not be a callable/'
- '/Property Rebing\\GraphQL\\Support\\Field\:\:\$name \(string\) does not accept int\|string/'
- '/Parameter #1 \$name of method Rebing\\GraphQL\\Support\\Type\:\:getFieldResolver\(\) expects string, int\|string given/'
# tests/Unit/EndpointTest.php
- '/Method Illuminate\\Foundation\\Testing\\TestResponse\:\:assertSee\(\) invoked with 2 parameters, 1 required/'
reportUnmatchedIgnoredErrors: true
7 changes: 5 additions & 2 deletions src/GraphQL.php
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@
use Rebing\GraphQL\Exception\TypeNotFound;
use Rebing\GraphQL\Support\Contracts\TypeConvertible;
use Rebing\GraphQL\Support\PaginationType;
use Symfony\Component\Debug\Exception\FatalThrowableError;

class GraphQL
{
@@ -418,7 +417,11 @@ public static function handleErrors(array $errors, callable $formatter): array
}

if (! $error instanceof Exception) {
$error = new FatalThrowableError($error);
$error = new \Exception(
$error->getMessage(),
$error->getCode(),
$error
);
Comment on lines +420 to +424
Copy link
Contributor Author

@exodusanto exodusanto Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrapped the error with the Exception class to be backward-compatibile with Laravel <= 6.x.
I had to remove the FatalThrowableError because it doesn't exist anymore on Symfony 5

}

$handler->report($error);
6 changes: 3 additions & 3 deletions tests/Unit/EndpointTest.php
Original file line number Diff line number Diff line change
@@ -163,9 +163,9 @@ public function testGetGraphqiQL(): void
$response = $this->call('GET', '/graphiql');

// Are we seeing the right template?
$response->assertSee('This GraphiQL example illustrates how to use some of GraphiQL\'s props');
$response->assertSee('This GraphiQL example illustrates how to use some of GraphiQL\'s props', false);
// The argument to fetch is extracted from the configuration
$response->assertSee('return fetch(\'/graphql\', {');
$response->assertSee("'x-csrf-token': xcsrfToken || ''");
$response->assertSee('return fetch(\'/graphql\', {', false);
$response->assertSee("'x-csrf-token': xcsrfToken || ''", false);
}
}
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
use Illuminate\Contracts\Debug\ExceptionHandler;
use Mockery;
use Rebing\GraphQL\Tests\TestCase;
use Symfony\Component\Debug\Exception\FatalThrowableError;
use Throwable;

class EngineErrorInResolverTest extends TestCase
{
@@ -29,7 +29,7 @@ protected function resolveApplicationExceptionHandler($app)
$handlerMock
->shouldReceive('report')
->with(Mockery::on(
function (FatalThrowableError $error) {
function (Throwable $error) {
// Using a regex here because in some cases the message gets prefixed with "Type error:"
$this->assertRegExp('/Simulating a TypeError/', $error->getMessage());