wpgraphql-acf icon indicating copy to clipboard operation
wpgraphql-acf copied to clipboard

Using the same "GraphQL Type Name"s produces data issues

Open alecarg opened this issue 1 year ago • 2 comments

Hello! First of all, thanks for the great plugin, loving the push.

I found that when setting the same "GraphQL Type Name" for different "Field groups" ie.:

Screenshot 2024-03-19 at 05 20 36 (meaning I have many others set as "acf" too)

.. then all of a sudden when querying my entity's acf property, I seem to get access to all other acf properties' from other entities:

Screenshot 2024-03-19 at 05 19 38

.. and to prove that those properties aren't in my rutinas entity:

Screenshot 2024-03-19 at 05 17 46

--

Is this a bug? Or am I misuing the "GraphQL Type Name"? I found it very annoying to have to access the data for each object by specifying the entity name every time. To make things worse, when attempting to "save" data via the REST API (as mutations aren't yet supported), then the field must be named acf, hence why I thought I'd kill 2 birds with 1 stone if I just set them all to be acf in the first place.

Any ideas on how to fix/improve on the above?

alecarg avatar Mar 19 '24 05:03 alecarg

@alecarg it looks like you're using the new WPGraphQL for ACF v2.*+?

I'm going to transfer this issue to the repo where that plugin is maintained.

jasonbahl avatar Mar 26 '24 17:03 jasonbahl

I found it very annoying to have to access the data for each object by specifying the entity name every time

@alecarg this is how GraphQL works. You are explicit about the Types and Fields that you want to consume as an API consumer.

GraphQL cannot have duplicate Types of the same name, so by assigning multiple ACF Field Groups the type name "acf" it creates a conflict. (Similar to if you tried to register multiple post types with the name "post", you would have issues as well).

I think the real bug here is that the ACF UI doesn't have validation preventing you from saving a GraphQL field group and assigning it a GraphQL Type Name that already exists. (see: #87)

jasonbahl avatar Mar 26 '24 18:03 jasonbahl

Closing in favor of #87

jasonbahl avatar Aug 23 '24 22:08 jasonbahl