Closed jasonbahl closed 2 years ago
I created a video to document what I'm experiencing: https://youtu.be/TcG8CdSif90
As noted in the video, this appears to impact User -> Post connections throughout, not just for models created by ACM.
Having ACM active breaks existing queries such as:
{
users {
nodes {
id
name
posts { # posts authored by the user are not returned when ACM is active
nodes {
title
}
}
}
}
}
@jasonbahl which version of ACM are you using?
I can't reproduce this bug on a fresh site with just ACM and WPGraphQL installed. I imported the JSON data provided above, created a few posts, and used the queries shown here and I get the posts and rabbits expected.
@mindctrl I'm using ACM v0.9.0 and WPGraphQL v1.6.7
@mindctrl I'll try and isolate further. I do have a few other plugins active, so I'll spin up an environment with nothing other than ACM + WPGraphQL and see if I can reproduce.
@mindctrl after going back and forth in Slack with you, we determined that the bug was related to a custom taxonomy I had registered named author
.
The taxonomies aren't included in the import/export of ACM Models (probably should be or have a separate import/export for them?)
This is why it wasn't easy to reproduce on your end initially.
I had a taxonomy registered as such:
Even though the Taxonomy is registered only to the Books
Model, it appears to be affecting queries of other models, including core post types such as posts.
Let me see if I can reproduce this without ACM, just registering an Author
taxonomy in code with WPGraphQL 🤔
Ok, I tried to reproduce by registering an author
taxonomy with Custom Post Type UI, but it prevented me from creating it because of this: https://developer.wordpress.org/reference/functions/register_taxonomy/#reserved-terms
Of course, CPT UI just said I couldn't create it, I had to dig to find out why.
I think our error message could be better for users than that of CPT UI. Even I, a seasoned WordPress user, didn't know why they were rejecting this. I checked my taxonomies and I did not have an author
one already, so the error message was misleading.
I realized after digging that it was a reserved keyword because of how WP_Query works, but not because it's a duplicate taxonomy as the error message made it seem.
Jira ticket for this is: https://wpengine.atlassian.net/browse/MTKA-1332
The SQL Query generated for WPGraphQL connections from a user to posts of any post_type includes an error.
This appears to only be the case when using ACM to generate post types. I believe it's something to do with the Post 2 Post mechanism included in ACM, but not quite sure yet.
To reproduce
Expected behavior
When posts of a custom post type are queried in connection to their author, I expect to see posts of said type.
I can get correct behavior when registering the post_type via code or via Custom Post Type or CPT UI, then making the same query.
GraphQL Query:
JSON export of ACM models:
ERROR IN SQL
Expected SQL: