Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

ACF Select Field can't return Array format #318

Closed
ShahriarKh opened this issue Apr 5, 2022 · 7 comments
Closed

ACF Select Field can't return Array format #318

ShahriarKh opened this issue Apr 5, 2022 · 7 comments

Comments

@ShahriarKh
Copy link

For some reason, I can't use the Array for return format and it throws an error.
I also saw #296 , #267 and #31, but none of them has a solution for a Headless WordPress. (My frontend is made with react, so theme functions doesn't help)

Plugin Versions:

WP GraphQL: 1.7.2
WPGraphQL for Advanced Custom Fields: 0.5.3
ACF: 5.12

This is my field:

enter image description here


I created a sample post and selected "green" and "blue". This is what happens:

Works correctly when I choose "value" as Return Format:

enter image description here

Works correctly when I choose "label" as Return Format:

enter image description here

Throws error when I choose "Array (Both) as Return Format:

enter image description here

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

And this is the error explanation when I turn on the Debug mode:

{
  "errors": [
    {
      "debugMessage": "Expected a value of type \"String\" but received: {\"value\":\"g1\",\"label\":\"Green\"}",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 6,
          "column": 9
        }
      ],
      "path": [
        "posts",
        "nodes",
        0,
        "colors",
        "colors",
        0
      ]
    },
    {
      "debugMessage": "Expected a value of type \"String\" but received: {\"value\":\"b1\",\"label\":\"Blue\"}",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 6,
          "column": 9
        }
      ],
      "path": [
        "posts",
        "nodes",
        0,
        "colors",
        "colors",
        1
      ]
    }
  ],
  "data": {
    "posts": {
      "nodes": [
        {
          "title": "Test",
          "colors": {
            "colors": [
              null,
              null
            ]
          }
        }
      ]
    }
  },
  "extensions": {
    "debug": []
  }
}

How can I fix this?
(also on StackExchange)

@metawise
Copy link

I'm facing a similar issue. Did you find any solutions yet?

@ShahriarKh
Copy link
Author

I'm facing a similar issue. Did you find any solutions yet?

Nope 😕. I'm handling it in frontend.

@marco910
Copy link

I'm also facing the same issue

@mkosak
Copy link

mkosak commented Apr 5, 2023

The same for me. Did anyone found any workaround?

@2xSamurai
Copy link

+1 for this issue. I'm also facing it.

@jasonbahl
Copy link
Contributor

This has been resolved in the new version of WPGraphQL for ACF being re-architected here: https://github.com/wp-graphql/wpgraphql-acf

That version of the plugin is what we'll be supporting going forward.

It's a complete rewrite of the plugin and will be moving from beta to stable in the near future.

We recommend making the switch sooner than later. A formal upgrade guide and docs will be out soon!

@jasonbahl
Copy link
Contributor

Ah, perhaps I mis-spoke about this being resolved fully in the new version?

We do have this open issue on the new repo as well, which seems to relate to this: wp-graphql/wpgraphql-acf#105

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants