thecodingmachine / graphqlite

Use PHP Attributes/Annotations to declare your GraphQL API
https://graphqlite.thecodingmachine.io
MIT License
555 stars 95 forks source link

ExtendType and Type with class argument don't work #634

Closed semnickolas closed 10 months ago

semnickolas commented 10 months ago

Explain please, maybe I don't undestand, but next code doesn't work?! Project develop on PHP 8.2 and Symfony 6

#[Type]
class SomeEntity 
{
     public function getSome(): string
    {
        return 'some text';
    }
}

#[ExtendType(class: SomeEntity::class)] //tried #[Type(class: SomeEntity::class)] - no result
class SomeType 
{
    #[Field]
    public function getSome(SomeEntity $source): string
    {
        return $source->getSome() . ' text';
    }
}

class SomeController
{
    #[Query(name: 'someTestQuery')]
    /**
     * @return SomeType[]|SomeEntity[] // tried single return type with both variants, no results
     */
    public function someAction(): array
    {
        return [new SomeEntity()];
    }
}