-
Notifications
You must be signed in to change notification settings - Fork 122
Relationship field query errors out for anonymous when set to some non-published post #85
Comments
@jasonbahl let me know if you need any more information here to replicate this. |
I've just replicated this as well, with an unpublished post (using a custom post type, if that helps isolate the issue). I realized it when I didn't see the error running the same query in an admin user session. |
@mdrayer @peterjanes I'm not currently able to replicate this. I've tried on WPGraphQL v0.4.0 and the upcoming WPGraphQL v0.5.0. Maybe I'm missing a detail with my Field Group or Field configuration? Here's what I'm doing to try and replicate, and I'm not getting errors:
Perhaps you can share your Field Group registration(s) with me so I can replicate exactly? |
The issue isn't with deleted posts, it is with posts that are set to private or draft. For instance, instead of deleting the "Delete Me" post, set it to Private and run the query again as an anon user. |
Ah. 🤦♂ I guess I need to read the details better. Let me try again 👀 |
Ah. Ok. Makes much more sense now that I try with a private post. I think the best thing to do here is going to be to adjust the shape of this field to return the node one level deeper. Like:
The reason the error is getting thrown is because it's expecting to resolve to a Type, but if we nest it a level, the field that leads to the I'll play with this and see what I can come up with. 🤔 |
Just ran into this with the |
This is still happening with WP GraphQL v0.6.1, WP GraphQL for ACF v0.3.1. |
I have the same issue. Any working solution? |
Hello, thanks for the awesome work. |
Just ran into this with a Also I think it's related to this issue too: #100 |
Just to say it, this is an incredibly frustrating bug. It's very hard to discover this in development, and easy for the user to draft something and then this breaks the site in some other unrelated place. What's worse is GraphiQL will show the query working, so it's really hard to track it down in the real world. Legit spent 6 hours today only to come back to this error from a year ago that I already knew about. 🤦♂ |
Adding
|
I ran into this bug with the latest WPGraphQL (v0.11.0 at the time of this writing) and the current WPGraphQL ACF plugin (v0.3.5) and I've been experiencing it for a while now. It really make it hard to use ACF with Gatsby and I've resulted in writing a wrapper around node-fetch and passing that wrapped fetch to the options of Any help would be greatly appreciated! |
Just ran into this with the |
I've worked around this with a WP filter which calls get_posts() with the relationship's value; get_posts only returns published posts by default so getting the ID's from that collection will remove draft/deleted posts.
|
I believe what needs to happen to resolve this is to update the resolver for relationship fields to use the DataLoader instead of loading posts directly. |
👋🏻 This is resolved in the upcoming v0.6.0 release. More information here: #173 (comment) |
Say you have a post relationship field called "Related Content" in a Post custom fields group (say "Post Fields"). If a selected post within that field is set to private, draft, or some other state where the anonymous user cannot view it; the query will return an error. I would instead expect the system to simply return
null
(which it does) and give no errors.Example query:
Result:
Tested on:
The text was updated successfully, but these errors were encountered: