Releases: nuwave/lighthouse
Remove backticks in QueryBuilder (Postgres)
v2.0.3 remove backticks (postgres)
Initial Lumen Support
Thanks to the help of @4levels and @kikoseijo, Lumen has initial support! If you run into any problems please submit an issue!
Client Directives
You can now define client side directives in your schema files. Some helper methods/traits will be provided in the future that you can use to help resolve those directives.
Server Side
# Server Side - Defines a client directive that can be applied to fields
directive @cache(key: String) on FIELD
# ...
type Query {
foo: String
}
Client Side
query Foo {
foo @cache("client-cache-key")
}
Include default eager loads
If you're using the hasMany
directive and you're connected model has default eager loading Lighthouse will now pull in those relations automatically.
For example, if you have a model:
class Post extends Model
{
protected $with = ['comments'];
}
a schema like this:
type Post {
author: [Comment!]! @hasMany
}
Lighthouse will automatically eager load the author
relationship whenever a Post
type is queried.
Eloquent Argument Filters
Created @where
, @whereBetween
, @whereNotBetween
, @eq
, @notEq
, @in
, @notIn
argument directives to filter queries.
type User {
id: ID!
name: String
email: String
}
type Query {
# filter users with an `id` in the provided array
users(include: [Int] @in(key: "id")): [User!]!
@paginate(model: "Tests\\\Utils\\\Models\\\User")
}
Until docs are released, check out the tests here.
Add missing facade
v2.0.1 add missing facade
Allow custom error formatting
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
public function register()
{
// ...
// Register custom error formatting
\GraphQL::error(function ($error, $e) {
$previous = $e->getPrevious();
if ($previous && $previous instanceof \Nuwave\Lighthouse\Support\Exceptions\ValidationError) {
$error['status_code'] = 422;
}
return $error;
});
}
}
Custom Validators
First, create a class that extends the new validator
// app/Http/GraphQL/Validators/MyCustomValidator.php
use Nuwave\Lighthouse\Support\Validator\Validator;
class MyCustomValidator extends Validator
{
public function rules()
{
// return array of rules...
}
}
Add validate directive to your schema:
extend type Mutation {
createFoo(input: FooInput!): FooPayload
@validate(validator: "App\\Http\\GraphQL\\Validators\\MyCustomValidator")
}
Lighthouse v2.0
v2.0.0 lighthouse version 2.0
Walkthrough Release
Final pre-release before v2.0 which will be cut tonight or tomorrow!