Skip to content
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

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

Open
vstrelianyi opened this issue Oct 13, 2021 · 12 comments
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@vstrelianyi
Copy link

vstrelianyi commented Oct 13, 2021

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
Copy link
Contributor

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

@vstrelianyi
Copy link
Author

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

@vstrelianyi
Copy link
Author

image

@vstrelianyi
Copy link
Author

yes, you can select several options
image

@vstrelianyi
Copy link
Author

btw I have found the same issue here in acf graphql plugin repo
wp-graphql/wp-graphql-acf#155

@ardiewen
Copy link
Contributor

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
Copy link
Author

That would be great! Thx a lot!

@ardiewen
Copy link
Contributor

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.

@vstrelianyi
Copy link
Author

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

@kidunot89 kidunot89 added bug Something isn't working duplicate This issue or pull request already exists labels Jan 13, 2022
@CesarBenavides777
Copy link

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
Copy link
Member

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

@CesarBenavides777
Copy link

@kidunot89 Let me get this tested and confirm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants