lighthouse
lighthouse copied to clipboard
Ensure the schema matches the models in ValidateSchema
What problem does this feature proposal attempt to solve?
Large parts of our schema consists of type
definitions that match our models. Calling php artisan lighthouse:validate-schema
does not validate that fields line up correctly with the models attributes and relations.
Which possible solutions should be considered?
php artisan lighthouse:validate-schema
should catch as many errors as possible.
First, we would need to identify which types should correspond to a model. That information can come from:
- explicit
@model
directive - usage of the type in fields with directives that presume model usage, such as
@all
,@create
Validating that a type lines up with a model requires that Lighthouse is able to check if each field is able to be resolved. Possible resolvers are:
- explicit resolver directives
- attributes (requires PHPDoc annotations in the model)
- relations (requires type annotations on the relationship method, preferrably PHPDoc annotations with generic types)