galahad / graphoquent
Expose your eloquent models as GraphQL queries and mutations
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:project
pkg:composer/galahad/graphoquent
Requires
- php: >=5.6
- illuminate/database: 5.3.*|5.4.*|5.5.*
- illuminate/http: 5.3.*|5.4.*|5.5.*
- illuminate/routing: 5.3.*|5.4.*|5.5.*
- illuminate/support: 5.3.*|5.4.*|5.5.*
- phpdocumentor/reflection-docblock: ^3.2
- webonyx/graphql-php: ~0.9.13
Requires (Dev)
- mockery/mockery: ^0.9.9
- phpunit/phpunit: ~5.7.19
This package is auto-updated.
Last update: 2025-10-29 02:22:28 UTC
README
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 (or- nullif 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; }