-
-
Notifications
You must be signed in to change notification settings - Fork 137
Error when querying products that are ACF relationship field items #253
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
Comments
@jholman101 I have located this issue, but it will take some changes in both WPGraphQL ACF and WooGraphQL for it to be resolved. I've opened a PR in WPGraphQL ACF with the changes needed there. If they get merged quickly, I'll include the WooGraphQL changes in Release v0.5.1 |
That is awesome news @kidunot89. Thank you so much for all you're doing with these plugins. It is truly appreciated. |
Hey @kidunot89. Any update on this? Not sure if there's something I can do in the meantime that's filterable. Looks like @jasonbahl merged in some changes here: wp-graphql/wp-graphql#1391 I do see that there's a closed PR that didn't get merged in the ACF plugin here: wp-graphql/wp-graphql-acf#124 Thanks! Here's my error message (flexible content field that references products) {
"errors": [
{
"debugMessage": "Abstract type Page_Mediamodule_MediaModules_ProductModule_Products must resolve to an Object type at runtime for field Page_Mediamodule_MediaModules_ProductModule.products with value \"instance of WPGraphQL\\Model\\Post\", received \"Product\". Either the Page_Mediamodule_MediaModules_ProductModule_Products type should provide a \"resolveType\" function or each possible type should provide an \"isTypeOf\" function.",
"message": "Internal server error",
"extensions": {
"category": "internal"
},
"locations": [
{
"line": 7,
"column": 13
}
],
"path": [
"pages",
"nodes",
0,
"mediaModule",
"mediaModules",
6,
"products",
0
]
}
] |
@jacobarriola Yea, but it's tied up in the v0.6.0 release right now. Try to get that out this week or beginning of next week. |
All good, @kidunot89 👍🏽 I appreciate all of the work. Ping me if you need testers. I'm knee-deep in a WooGraphQL project atm, so there's lots of stuff for me to test. |
I'm having this problem too, does any of those PR were merged? |
The same problem. Is there a chance that it will be resolved? |
I have also just come across this problem when using a Note: I have also tried the relationship with a standard I followed the breadcrumb here wp-graphql/wp-graphql#1388 | wp-graphql/wp-graphql#1391 which looks to have been merge but doesn't seem to fix this bug. Any ideas @jasonbahl @kidunot89 Thanks in advance. |
Really sorry to bump this up so soon after posting and I also appreciate this is OS and that it is a: as and when/if warrants scenario with importance or detriment to the plugin. I understand this would most likely need further investigation before being able to comment or fix but in the interim is there anything as a workaround that could perhaps band-aid this issue? I have attempted to use the Example Filter Use: filter shown here (wp-graphql/wp-graphql#1391) (also provided below) to intercept this model behaviour. On logging the filters args within side the add_filter( 'graphql_dataloader_pre_get_model', function( $model, $entry, $key, $this ) {
if ( $entry instanceof \WP_Post && 'product' === $entry->post_type ) {
return new \WPGraphQL\WooCommerce\Model\Product( $entry );
}
return $model;
}, 10, 4 ); Thanks in advance. UPDATE I have done some further debugging in to the WP-GraphQL plugin at the point this error is displayed. When dumping out the string(42) "Page_Pagesections_Sections_PopularHolidays"
string(30) "WPGraphQL\Type\WPInterfaceType"
string(7) "Product" |
Yes, there is an update on this issue here: #449 (comment) |
Hi, yes I saw it, but I have the latest version of the plugins but the errors persists |
The relationship field in ACF establishes connections to other Post Types. Product is a Post Type, but WooGraphQL resolves Products differently than WPGraphQL resolves any other type of Post Type, so fields like this that expect a Post model to be returned don't get a Post model returned, but instead a Product.
To Reproduce
Have wp-graphql, wp-graphql-woocommerce, wp-graphql-acf and wp-graphiql installed.
Add an ACF Field group to posts, example field group export below:
[ { "key": "group_5e85643c0cc84", "title": "Testing Product Relationship issue", "fields": [ { "key": "field_5e85644be0a13", "label": "Post Products", "name": "post_products", "type": "relationship", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "show_in_graphql": 1, "post_type": [ "product" ], "taxonomy": "", "filters": [ "search", "post_type", "taxonomy" ], "elements": "", "min": "", "max": "", "return_format": "object" } ], "location": [ [ { "param": "post_type", "operator": "==", "value": "post" } ] ], "menu_order": 0, "position": "normal", "style": "default", "label_placement": "top", "instruction_placement": "label", "hide_on_screen": "", "active": true, "description": "", "show_in_graphql": 1, "graphql_field_name": "TestingProductRelationshipIssue" } ]
Run query in wp-graphiql. Sample query below:
query SampleQuery { __typename posts(first: 10) { edges { node { title TestingProductRelationshipIssue { postProducts { ... on SimpleProduct { id name sku } } } } } } }
Expected behavior
Should return results without errors
Screenshots
https://slack-files.com/T3PDM1KRC-F0118V1GM0D-eab1d0676d
Additional context
Slack message thread about the issue:
https://wp-graphql.slack.com/archives/CCYJRDN4A/p1585794638031200
The text was updated successfully, but these errors were encountered: