Closed webard closed 6 months ago
Laravel, Lighthouse and Lara ASP
What versions are you using?
For the first look, it seems lighthouse issue. The CanAction
type defined in BaseCanDirective::commonTypes()
, but the method called in CanFindDirective::definition()
only. So seems if @canFind
directive is not used in the schema, the type will never add to the schema.
As workaround you can try (not tested)
Route::get('/graphql-sdl', static function (): string {
// Will load all types from the directive
$resolver = Container::getInstance()->make(\LastDragon_ru\LaraASP\GraphQLPrinter\Contracts\DirectiveResolver::class);
$resolver->getDefinition('canFind');
// end
$schema = Container::getInstance()->make(SchemaBuilder::class)->schema();
$printer = Container::getInstance()->make(Printer::class);
$printed = $printer->print($schema);
return (string) $printed;
});
if
@canFind
directive is not used in the schema, the type will never add to the schema.
I don't use this directive, so why Schema Printer require type definitions for this directive?
Because only this directive will add CanAction
type definition)
As I said, it is related how Lighthouse adds/loads own types. And thus there is nothing to do with our side.
Hello,
I have latest version of Laravel, Lighthouse and Lara ASP. I have simple code that prints schema in SDL:
but that code generates error:
But this type should be registered by Lighthouse: https://lighthouse-php.com/6/api-reference/directives.html#can-family-of-directives.
There is no info in Lighthouse docs about adding additional ServiceProvider or something.