OneToMany relation when using custom identifier in GraphQL returns null/wrong data

I am using api-platform with Symfony 5 to build GraphQl API.

When using custom identifier that is not a primary key, OneToMany result set returns null or wrong data. This issue is caused because when fetching data from OneToMany table, the custom identifier value is used instead of primary key.


Table Blog has a custom identifier slug and primary key id. This table have a OneToMany relationship with Table Image

These are the queries made while fetching data:

SELECT AS id_0, b0_.content AS content_1,  b0_.slug AS slug_3 FROM blog b0_ WHERE b0_.slug = "highest peak"

SELECT AS id_0, i0_.src AS src_1 FROM image i0_ WHERE i0_.blog_id = "highest peak" ORDER BY ASC LIMIT 30

While fetching from image , Blog ID should be sent in parameters but slug is used.

However, things are working fine in REST. Problem is encountered while using GraphQL.

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *