galahad/graphoquent
Graphoquent
Graphoquent is a Laravel packages that turns Eloquent models into queryable GraphQL objects.
Automatic Type Inference
By default, Graphoquent tries to infer your model's type from three places:
- The model's
$castsarray - The model's
$datesarray - The model's
@propertyand@property-readDocBlock annotations
Given the following model:
/**
* @property int $count
*/
class Foo extends Model
{
use \Galahad\Graphoquent\Queryable;
protected $casts = [
'stars' => 'float',
];
protected $dates = [
'created_at',
];
}
Graphoquent will build the following GraphQL Type:
type Foo {
count: Int
stars: Float
created_at: String
}
Authorization
Gates & Policies
Graphoquent uses Laravel Gates for default authorization:
expose: Can this user (ornullif not logged in) use introspection to lear about this Type?
Custom
You may provide custom authorization for any Model by defining an
authorizeGraphQL method on the model:
public function authorizeGraphQL($actor, $ability)
{
if ('expose' === $ability) {
return true;
}
return $actor && $actor->id === $this->owner_id;
}
Related Packages
rebing/graphql-laravel-select-fields
SelectFields (Eloquent eager loading) for rebing/graphql-laravel - optimizes Gra...
1,893
0
optigov/eloquent-graphql
This package provides automatic creation of GraphQL types and fields from Eloque...
3,238
4
hootlex/laravel-friendships
This package gives Eloquent models the ability to manage their friendships.
128,287
698
kodeine/laravel-acl
Light-weight role-based permissions for Laravel 5 built in Auth system.
365,109
775