Package Data | |
---|---|
Maintainer Username: | inxilpro |
Package Create Date: | 2017-08-16 |
Package Last Update: | 2017-08-18 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-12-15 15:03:53 |
Package Statistics | |
---|---|
Total Downloads: | 6 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 4 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Graphoquent is a Laravel packages that turns Eloquent models into queryable GraphQL objects.
By default, Graphoquent tries to infer your model's type from three places:
$casts
array$dates
array@property
and @property-read
DocBlock annotationsGiven 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
}
Graphoquent uses Laravel Gates for default authorization:
expose
: Can this user (or null
if not logged in) use introspection
to lear about this Type?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;
}