A framework for serving GraphQL from Laravel
MIT License
Bot releases are hidden (Show)
Published by chrissm79 over 6 years ago
Published by chrissm79 over 6 years ago
Published by chrissm79 over 6 years ago
Updated Doc Site: https://lighthouse-php.netlify.com/
Published by chrissm79 over 6 years ago
Going to freeze updates for v2.1
, all PRs going to master will be for v2.2
and bugfixes for v2.1
should be merged with this new branch.
Published by chrissm79 over 6 years ago
Created @security
directive which can be set on the Query
type with the following options:
type Query @security(introspection: false, depth: 10, complexity: 100) {
# ...
}
A new @complexity
directive has been created which can be attached to fields to calculate complexity (default calculation provided for relationships):
type User {
# default calculation
posts: [Post!]! @hasMany @complexity
# custom calculation
posts: [Post!]! @hasMany @complexity(resolver: "App\\Http\\GraphQL\\Complexity::userPosts")
}
Published by chrissm79 over 6 years ago
Published by chrissm79 over 6 years ago
Published by chrissm79 over 6 years ago
Published by chrissm79 over 6 years ago
Published by chrissm79 over 6 years ago
Published by chrissm79 over 6 years ago
Published by chrissm79 over 6 years ago
Thanks to the help of @4levels and @kikoseijo, Lumen has initial support! If you run into any problems please submit an issue!
Published by chrissm79 over 6 years ago
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")
}
Published by chrissm79 over 6 years ago
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.
Published by chrissm79 over 6 years ago
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.
Published by chrissm79 over 6 years ago
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;
});
}
}