ACF Relationship Field throws an error in Gatsby
See original GitHub issueI’m running into a problem, where a query throws an error, which works on the remote GraphiQL endpoint, when using an ACF Relationship field.
query {
page(id: "730", idType: DATABASE_ID) {
acf {
content {
... on Page_Acf_Content_FeaturedNews {
news {
... on NewsEntry {
id
}
}
}
}
}
}
}
returns on the remote GraphiQL:
{
"data": {
"page": {
"acf": {
"content": [
{
"news": [
{
"id": "cG9zdDoyNjI4"
},
{
"id": "cG9zdDoyNjMy"
},
{
"id": "cG9zdDoyNjE3"
}
]
}
]
}
}
}
}
but the same query throws an error in Gatsby:
query MyQuery {
wpPage(databaseId: {eq: 730}) {
acf {
content {
... on WpPage_Acf_Content_FeaturedNews {
news {
... on WpNewsEntry {
id
}
}
}
}
}
}
}
result:
{
"errors": [
{
"message": "Cannot read property 'id' of null",
"locations": [
{
"line": 6,
"column": 11
}
],
"path": [
"wpPage",
"acf",
"content",
5,
"news"
],
"stack": [
"TypeError: Cannot read property 'id' of null",
" at reduce (~/node_modules/gatsby-source-wordpress-experimental/src/steps/create-schema-customization/transform-fields/transform-union.js:49:27)",
" at Array.reduce (<anonymous>)",
" at resolver (~/node_modules/gatsby-source-wordpress-experimental/src/steps/create-schema-customization/transform-fields/transform-union.js:46:28)",
" at wrappedTracingResolver (~/node_modules/gatsby/src/schema/resolvers.ts:518:14)",
" at resolveFieldValueOrError (~/node_modules/graphql/execution/execute.js:467:18)",
" at resolveField (~/node_modules/graphql/execution/execute.js:434:16)",
" at executeFields (~/node_modules/graphql/execution/execute.js:275:18)",
" at collectAndExecuteSubfields (~/node_modules/graphql/execution/execute.js:713:10)",
" at completeObjectValue (~/node_modules/graphql/execution/execute.js:703:10)",
" at completeAbstractValue (~/node_modules/graphql/execution/execute.js:660:10)",
" at completeValue (~/node_modules/graphql/execution/execute.js:585:12)",
" at completeValueCatchingError (~/node_modules/graphql/execution/execute.js:495:19)",
" at ~/node_modules/graphql/execution/execute.js:618:25",
" at Array.forEach (<anonymous>)",
" at forEach (~/node_modules/iterall/index.js:83:25)",
" at completeListValue (~/node_modules/graphql/execution/execute.js:614:24)",
" at completeValue (~/node_modules/graphql/execution/execute.js:573:12)",
" at ~/node_modules/graphql/execution/execute.js:492:16",
" at runMicrotasks (<anonymous>)",
" at processTicksAndRejections (internal/process/task_queues.js:93:5)",
" at async Promise.all (index 0)",
" at async Promise.all (index 0)",
" at async Promise.all (index 0)"
]
}
],
"data": {
"wpPage": {
"acf": {
"content": [
{
"news": null
}
]
}
}
}
}
kolle-on-xps :: Development/ » npx gatsby info
System: OS: Linux 5.8 Ubuntu 20.10 (Groovy Gorilla) CPU: (8) x64 Intel® Core™ i7-10510U CPU @ 1.80GHz Shell: 5.8 - /usr/bin/zsh Binaries: Node: 14.15.1 - /usr/bin/node Yarn: 1.22.4 - ~/.npm-global/bin/yarn npm: 6.14.8 - ~/.npm-global/bin/npm Languages: Python: 2.7.18 - /usr/bin/python Browsers: Firefox: 83.0 npmPackages: gatsby: ^2.24.91 => 2.27.0 gatsby-image: ^2.6.0 => 2.6.0 gatsby-link: ^2.4.16 => 2.6.0 gatsby-plugin-advanced-sitemap: ^1.5.6 => 1.5.6 gatsby-plugin-manifest: ^2.4.37 => 2.7.0 gatsby-plugin-netlify: ^2.3.25 => 2.6.0 gatsby-plugin-react-helmet: ^3.3.14 => 3.5.0 gatsby-plugin-react-svg: ^3.0.0 => 3.0.0 gatsby-plugin-sharp: ^2.6.43 => 2.9.0 gatsby-plugin-styled-jsx: ^3.5.0 => 3.5.0 gatsby-source-filesystem: ^2.3.37 => 2.6.1 gatsby-source-wordpress-experimental: ^3.1.3 => 3.1.3 gatsby-transformer-sharp: ^2.5.20 => 2.7.0
using WPGraphQL: 1.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (4 by maintainers)
Top GitHub Comments
It sure is…
Did anything further ever happen with this? I’m having the same issue with a flexible content field