wp-graphql / wp-graphql-woocommerce

Add WooCommerce support and functionality to your WPGraphQL server
https://woographql.com
GNU General Public License v3.0
647 stars 130 forks source link

querying acf relationship fields between CPT and Product returns an error #565

Open vstrelianyi opened 3 years ago

vstrelianyi commented 3 years ago

versions: WP 5.8.1 Woo 5.8.0 Graphql 1.6.5 WPGraphQL WooCommerce 0.10.4 Advanced Custom Fields PRO 5.10.2 WPGraphQL for Advanced Custom Fields 0.5.3

Steps: 1) I'm having a CPT - Auctions 2) Auction has an ACF Relationship field with Products 3) when I'm running the following query - I'm receiving an error

QUERY: image

ERROR: image

QUERY: query GET_AUCTIONS { auctions { nodes { title acf_auctions { auctionProduct { ... on SimpleProduct { id name databaseId commentCount } } } } } }

ERROR: { "errors": [ { "message": "Internal server error", "extensions": { "category": "internal" }, "locations": [ { "line": 6, "column": 9 } ], "path": [ "auctions", "nodes", 1, "acf_auctions", "auctionProduct", 0 ] } ], "data": { "auctions": { "nodes": [ { "title": "Auction 2", "acf_auctions": { "auctionProduct": null } }, { "title": "Auction 1", "acf_auctions": { "auctionProduct": [ null ] } } ] } }, "extensions": { "debug": [ { "type": "DEBUG_LOGS_INACTIVE", "message": "GraphQL Debug logging is not active. To see debug logs, GRAPHQL_DEBUG must be enabled." } ] } }

ardiewen commented 3 years ago

Hi @vstrelianyi can you post your Custom Field configuration? I'm wondering if you have the Select multiple values? option enabled.

vstrelianyi commented 3 years ago

Hi @ardiewen ! should I check for this option in ACF field configuration?

vstrelianyi commented 3 years ago

image

vstrelianyi commented 3 years ago

yes, you can select several options image

vstrelianyi commented 3 years ago

btw I have found the same issue here in acf graphql plugin repo https://github.com/wp-graphql/wp-graphql-acf/issues/155

ardiewen commented 3 years ago

Yeah interesting... definitely related to the acf schema filter as mentioned in the other post. However the solve seems to be on this repo. I will see if I can test a potential fix.

vstrelianyi commented 3 years ago

That would be great! Thx a lot!

ardiewen commented 3 years ago

Hi @vstrelianyi, you'll need two PRs to fix the issue:

568 on this repo

https://github.com/wp-graphql/wp-graphql-acf/pull/297 on the acf plugin repo

Please note the following:

1) This will only be a temp fix due to significant breaking changes in wp-graphql-acf in v0.6.0

2) You MUST set a "Filter by Post Type" like you have in your screenshot. Failing to do so will cause the default type of your field to become PostObjectUnion which will cause conflicts with wp-graphql-woocommerce and consequently throw an error.

vstrelianyi commented 3 years ago

Ok. will try that!, thx! so wp-graphql-acf v0.6.0 is on the way?

CesarBenavides777 commented 2 years ago

Hi @vstrelianyi, you'll need two PRs to fix the issue:

568 on this repo wp-graphql/wp-graphql-acf#297 on the acf plugin repo

Please note the following:

  1. This will only be a temp fix due to significant breaking changes in wp-graphql-acf in v0.6.0
  2. You MUST set a "Filter by Post Type" like you have in your screenshot. Failing to do so will cause the default type of your field to become PostObjectUnion which will cause conflicts with wp-graphql-woocommerce and consequently throw an error.

I think only https://github.com/wp-graphql/wp-graphql-acf/pull/297 on the acf plugin repo this edit is needed now thankfully.

kidunot89 commented 1 year ago

@vstrelianyi @CesarBenavides777 @ardiewen @asmartbear Is this still an issue in v0.12.1?

CesarBenavides777 commented 1 year ago

@kidunot89 Let me get this tested and confirm.