Skip to content

Conversation

shish
Copy link

@shish shish commented Feb 25, 2024

I have an object which has known properties accessible via properties, and some extra bits added at runtime accessible via \ArrayAccess syntax. graphql-php sees the \ArrayAccess and now it thinks that all my fields are null :(

My specific use-case is that I had a class like

#[Type]
class Post {
    #[Field]
    public string $title = "Untitled";
}

and everything was working fine, but then I turned it into

#[Type]
class Post implements ArrayAccess {
    #[Field]
    public string $title = "Untitled";

    // ...
    // implementing ArrayAccess methods for internal use
    // only and not exposing them to graphql at all
    // ...
}

and suddenly any query which referred to the "title" field started throwing Cannot return null for non-nullable field "Post.title"

@spawnia
Copy link
Collaborator

spawnia commented Feb 26, 2024

Please extend testDefaultResolverGrabsValuesOffOfCommonPhpDataStructures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants