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: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/1_Bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ labels: bug

### Versions:
- graphql-laravel Version: #.#.#
- Laravel Version: #.#.# <!-- remove if not applicable -->
- Lumen Version: #.#.# <!-- remove if not applicable -->
- Laravel Version: #.#.# <!-- Lumen is NOT supported! -->
- PHP Version: #.#.#

### Description:
Expand Down
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/3_Support_question.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Alternative you can also use our Slack workspace: https://join.slack.com/t/rebin

### Versions:
- graphql-laravel Version: #.#.#
- Laravel Version: #.#.# <!-- remove if not applicable -->
- Lumen Version: #.#.# <!-- remove if not applicable -->
- Laravel Version: #.#.# <!-- Lumen is NOT supported! -->
- PHP Version: #.#.#

### Question:
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@ on:

jobs:
integration:
strategy:
fail-fast: false
matrix:
integration: [laravel, lumen]
name: ${{ matrix.integration }}
name: laravel
runs-on: ubuntu-20.04
env:
COMPOSER_NO_INTERACTION: 1
Expand Down Expand Up @@ -53,4 +49,4 @@ jobs:

- run: composer install --prefer-dist --no-suggest

- run: tests/integration-${{ matrix.integration }}.sh
- run: tests/integration-laravel.sh
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CHANGELOG
--------------

## Breaking changes
- Support for Lumen has been removed
- Integrate laragraph/utils RequestParser [\#739 / mfn](https://github.com/rebing/graphql-laravel/pull/739)
- batched queries will only work with `POST` requests
This is due to `RequestParser` using `\GraphQL\Server\Helper::parseRequestParams` which includes this check
Expand Down
33 changes: 1 addition & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ It offers following features and improvements over the original package by

### Dependencies:

* [Laravel 6.0+](https://github.com/laravel/laravel) or [Lumen](https://github.com/laravel/lumen)
* [Laravel 6.0+](https://github.com/laravel/laravel)
* [GraphQL PHP](https://github.com/webonyx/graphql-php)


Expand All @@ -55,37 +55,7 @@ Review the configuration file:
config/graphql.php
```

#### Lumen (experimental!)

**1.** Add the following service provider to the `bootstrap/app.php` file
```php
$app->register(Rebing\GraphQL\GraphQLLumenServiceProvider::class);
```

**2.** Publish the configuration file
```bash
$ php artisan graphql:publish
```

**3.** Add the configuration to the `bootstrap/app.php` file
*Important:* this needs to be before the registration of the service provider
```php
$app->configure('graphql');
...
$app->register(Rebing\GraphQL\GraphQLLumenServiceProvider::class);
```

**4.** Review the configuration file
```php
config/graphql.php
```

The default GraphiQL view makes use of the global `csrf_token()` helper function.
Out of the box, this function is not available in Lumen.

To work this around:
- Point to your local GraphiQL view: change `graphql.view` to `'vendor/graphql/graphiql'`
- Modify your file `resources/views/vendor/graphql/graphiql.php` and remove the call

## Usage

Expand All @@ -94,7 +64,6 @@ To work this around:
- [Dependencies:](#dependencies)
- [Installation:](#installation)
- [Laravel 6.0+](#laravel)
- [Lumen (experimental!)](#lumen-experimental)
- [Usage](#usage)
- [Concepts](#concepts)
- [Data loading](#data-loading)
Expand Down
15 changes: 0 additions & 15 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -455,26 +455,11 @@ parameters:
count: 1
path: src/Support/UploadType.php

-
message: "#^Call to method get\\(\\) on an unknown class Laravel\\\\Lumen\\\\Routing\\\\Router\\.$#"
count: 3
path: src/routes.php

-
message: "#^Call to method post\\(\\) on an unknown class Laravel\\\\Lumen\\\\Routing\\\\Router\\.$#"
count: 3
path: src/routes.php

-
message: "#^PHPDoc tag @var for variable \\$queryTypesMap has no value type specified in iterable type array\\.$#"
count: 1
path: src/routes.php

-
message: "#^PHPDoc tag @var for variable \\$router contains unknown class Laravel\\\\Lumen\\\\Routing\\\\Router\\.$#"
count: 2
path: src/routes.php

-
message: "#^Parameter \\#2 \\$callback of function array_filter expects \\(callable\\(mixed, mixed\\)\\: bool\\)\\|null, Closure\\(array, string\\)\\: bool\\|null given\\.$#"
count: 1
Expand Down
8 changes: 1 addition & 7 deletions src/GraphQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,12 +469,6 @@ public static function routeNameTransformer(string $name, string $schemaParamete
$routeName = null;

if (count($multiLevelPath) > 1) {
if (Helpers::isLumen()) {
array_walk($multiLevelPath, function (string &$multiName): void {
$multiName = "$multiName:$multiName";
});
}

foreach ($multiLevelPath as $multiName) {
$routeName = !$routeName ? null : $routeName . '/';
$routeName =
Expand All @@ -483,7 +477,7 @@ public static function routeNameTransformer(string $name, string $schemaParamete
}
}

return $routeName ?: preg_replace($schemaParameterPattern, '{' . (Helpers::isLumen() ? "schema:$name" : $name) . '}', $queryRoute);
return $routeName ?: preg_replace($schemaParameterPattern, '{' . $name . '}', $queryRoute);
}

/**
Expand Down
17 changes: 1 addition & 16 deletions src/GraphQLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function query(Request $request, string $schema = null): JsonResponse

// If there are multiple route params we can expect that there
// will be a schema name that has to be built
$routeParameters = $this->getRouteParameters($request);
$routeParameters = $request->route()->parameters;

if (count($routeParameters) > 1) {
$schemaName = implode('/', $routeParameters);
Expand Down Expand Up @@ -213,21 +213,6 @@ public function graphiql(Request $request, string $schema = null): View
]);
}

/**
* @return array<string,string>
*/
protected function getRouteParameters(Request $request): array
{
if (Helpers::isLumen()) {
/** @var array<int,mixed> $route */
$route = $request->route();

return $route[2] ?? [];
}

return $request->route()->parameters;
}

/**
* In case batching is not supported, send an error back for each batch
* (with a hardcoded limit of 100).
Expand Down
35 changes: 0 additions & 35 deletions src/GraphQLLumenServiceProvider.php

This file was deleted.

5 changes: 0 additions & 5 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

class Helpers
{
public static function isLumen(): bool
{
return class_exists('Laravel\Lumen\Application');
}

/**
* Originally from \Nuwave\Lighthouse\Support\Utils::applyEach
*
Expand Down
19 changes: 5 additions & 14 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Support\Arr;
use Rebing\GraphQL\GraphQLController;
use Rebing\GraphQL\Helpers;

$router = app('router');
$schemaParameterPattern = '/\{\s*graphql\_schema\s*\?\s*\}/';
Expand All @@ -13,7 +12,7 @@
'prefix' => config('graphql.prefix'),
'middleware' => config('graphql.middleware', []),
], config('graphql.route_group_attributes', [])), function ($router) use ($schemaParameterPattern): void {
/** @var \Illuminate\Routing\Router|\Laravel\Lumen\Routing\Router $router */
/** @var \Illuminate\Routing\Router $router */

// Routes and controllers
$routes = config('graphql.routes');
Expand Down Expand Up @@ -86,9 +85,7 @@
]
);

if (!Helpers::isLumen()) {
$route->where($name, $name);
}
$route->where($name, $name);
}
}
} else {
Expand All @@ -110,7 +107,7 @@
'prefix' => config('graphql.graphiql.prefix', 'graphiql'),
'middleware' => config('graphql.graphiql.middleware', []),
], function ($router) use ($schemaParameterPattern): void {
/** @var \Illuminate\Routing\Router|\Laravel\Lumen\Routing\Router $router */
/** @var \Illuminate\Routing\Router $router */
$graphiqlController = config('graphql.graphiql.controller', GraphQLController::class . '@graphiql');

$graphiqlAction = ['uses' => $graphiqlController];
Expand All @@ -120,19 +117,13 @@
Rebing\GraphQL\GraphQL::routeNameTransformer($name, $schemaParameterPattern, '{graphql_schema?}'),
$graphiqlAction + ['as' => "graphql.graphiql.$name"]
);

if (!Helpers::isLumen()) {
$route->where($name, $name);
}
$route->where($name, $name);

$route = $router->post(
Rebing\GraphQL\GraphQL::routeNameTransformer($name, $schemaParameterPattern, '{graphql_schema?}'),
$graphiqlAction + ['as' => "graphql.graphiql.$name.post"]
);

if (!Helpers::isLumen()) {
$route->where($name, $name);
}
$route->where($name, $name);
}

$router->get('/', $graphiqlAction + ['as' => 'graphql.graphiql']);
Expand Down
100 changes: 0 additions & 100 deletions tests/integration-lumen.sh

This file was deleted.