api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.44k stars 868 forks source link

Call to protected method splitPropertyParts() from scope AbstractFilter #6515

Open danaki opened 2 months ago

danaki commented 2 months ago

api-platform v3.3

GraphQL error:

{
  "errors": [
    {
      "message": "Internal server error",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "producedItems"
      ],
      "extensions": {
        "debugMessage": "Call to protected method ApiPlatform\\Doctrine\\Orm\\Filter\\SearchFilter::splitPropertyParts() from scope ApiPlatform\\Doctrine\\Orm\\Filter\\AbstractFilter",
        "file": "C:\\work\\lionel-api\\vendor\\api-platform\\core\\src\\Doctrine\\Orm\\PropertyHelperTrait.php",
        "line": 66,
        "trace": [
          {
            "file": "C:\\work\\lionel-api\\vendor\\api-platform\\core\\src\\Doctrine\\Orm\\Filter\\SearchFilter.php",
            "line": 186,
            "call": "ApiPlatform\\Doctrine\\Orm\\Filter\\AbstractFilter::addJoinsForNestedProperty()"
          },
          {
            "file": "C:\\work\\lionel-api\\vendor\\api-platform\\core\\src\\Doctrine\\Orm\\Filter\\AbstractFilter.php",
            "line": 44,
            "call": "ApiPlatform\\Doctrine\\Orm\\Filter\\SearchFilter::filterProperty()"
          },
          {
            "file": "C:\\work\\lionel-api\\vendor\\api-platform\\core\\src\\Doctrine\\Orm\\Extension\\FilterExtension.php",
            "line": 63,
            "call": "ApiPlatform\\Doctrine\\Orm\\Filter\\AbstractFilter::apply()"
          },
          {
            "file": "C:\\work\\lionel-api\\vendor\\api-platform\\core\\src\\Doctrine\\Orm\\State\\CollectionProvider.php",
            "line": 74,
            "call": "ApiPlatform\\Doctrine\\Orm\\Extension\\FilterExtension::applyToCollection()"
          },

....

entity defined like so;

#[ORM\Entity(repositoryClass: ProducedItemRepository::class)]
#[ApiResource(
    security: "is_granted('ROLE_USER')",
    order: ['id' => 'DESC'],
    normalizationContext: ['groups' => ["produced_item:query"]],
    denormalizationContext: ['groups' => ["produced_item:mutation"]],
    operations: [
        new Get(),
        new GetCollection(),
        new Post(),
    ],
    graphQlOperations: [
        new Query(),
        new QueryCollection(),
        new Mutation(name: 'create'),
    ]
)]
#[ApiFilter(SearchFilter::class, properties: [
    "package.packageCode" => "exact",
])]
class ProducedItem
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column]
    protected ?int $id;

    #[ORM\ManyToOne(targetEntity: Package::class)]
    #[ORM\JoinColumn(nullable: false)]
    #[Groups(["produced_item:query", "produced_item:mutation"])]
    #[ApiProperty(readableLink: false, writableLink: false)]
    protected Package $package;

....

Failing GraphQL query:

{
  producedItems(
    package_packageCode: "000000000000000001"
  ) {
    edges {
      node {
        id
      } 
      cursor
    }
    pageInfo {
      endCursor
      startCursor
      hasNextPage
      hasPreviousPage
    }
    totalCount
  }
}
stale[bot] commented 3 days ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.