Skip to content

Type based on Laravel model ignores regular php properties #2687

Open
@tminich

Description

@tminich

Describe the bug

class Test extends Model
{
    public string $test = 'test';
}
type Test {
    test: String
}

This will always return null for test, it never reads the property.

Expected behavior/Solution

It should read the property value.

We are moving away from Laravel get___Attribute getters (which work) as the native php 8.4 virtual property syntax has much better IDE integration and static analysis, so this is a bug that could lead to easily missed mistakes. I guess the implementation uses Laravel array access to retrieve the values, which is imo fine, but it should fall back to trying regular php object properties in case that fails.

Note: A current workaround is using @rename to 'rename' the attribute to itself.

Lighthouse Version

6.57.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementA feature or improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions