Skip to content

No mapping found for field <field> on class <class> on graphql request when adding a getter with the same return type as a doctrine association #5200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MrSpider opened this issue Nov 17, 2022 · 2 comments

Comments

@MrSpider
Copy link

API Platform version(s) affected: 3.0.4

Description
When an entity has a getter with the same type as a relation the Link generated by the LinkFactory gets overriden by the link detected via the getter in LinkResourceMetadataCollectionFactory::mergeLinks.

How to reproduce

  1. Take api-platform demo app
  2. Add the following getter to Book.php
public function getSomeImportantReview(): Review
{
    return new Review();
}
  1. Execute the following graphql query
{
  books {
    edges {
      node {
        id
        reviews {
          edges {
            node {
              id
            }
          }
        }
      }
    }
  }
}
  1. You should receive the following error message
"No mapping found for field 'someImportantReview' on class 'App\\Entity\\Book'.",

Possible Solution
Depending on whether this usage should be supported the Links generated by LinkFactory::createLinksFromRelations should only include doctrine relations and no relations detected by getter only.

Additional Context

@MrSpider MrSpider changed the title No mapping found for field <field> on class <class> on graphql request when adding a getter with the same type as a doctrine association No mapping found for field <field> on class <class> on graphql request when adding a getter with the same return type as a doctrine association Nov 17, 2022
@soyuka soyuka added the GraphQL label Nov 21, 2022
@alanpoulain
Copy link
Member

I think it has been fixed by #5169.

@stale
Copy link

stale bot commented Mar 20, 2023

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.

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

No branches or pull requests

3 participants