graphql-php
graphql-php copied to clipboard
If an object implements \ArrayAccess, check both array value and property
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"
Please extend testDefaultResolverGrabsValuesOffOfCommonPhpDataStructures.