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

CheckboxControl and RadioControl fields causing ApolloError: Internal server error #1899

Open
1 task done
jan-clockworkwp opened this issue May 30, 2024 · 4 comments
Open
1 task done
Labels
needs: author response Pending information from the author

Comments

@jan-clockworkwp
Copy link

Description

While working on a custom block and trying to use RadioControl and/or CheckboxControl fields, I am facing an ApolloError: Internal server error on the frontend. I have followed instructions from the official docs and #1573. Everything seems to be working; fields are properly rendered in the WP Admin, GraphQL schema is updated, the codegen script is not complaining either, the attribute is available for autocomplete when writing a query in GraphiQL. However, once the query is run, the following ApolloError is triggered. Below is an example of the error for the linkShow custom block attribute:

"errors": [
    {
      "debugMessage": "Undefined array key \"linkShow\"",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 226,
          "column": 11
        }
      ],
      "path": [
        "page",
        "editorBlocks",
        0,
        "attributes",
        "linkShow"
      ]
    }
  ],

This issue is not occurring for other custom attributes, only for these two (there may be others with a similar issue, but I have not tested them yet). I have tried various names for the custom attribute and played with different combinations of default values to no avail. Is there any better way to debug these ApolloErrors? Thanks for looking into this.

Steps to reproduce

  1. Clone the block-support example project.
  2. Modify block-b by adding new whatever named custom attribute with or without a default value, for example:
"test": {
    "type": "boolean",
 },
  1. Modify Component.js file by adding new attribute to the editorFields config:
test: {
    label: 'Checkbox test',
    location: 'inspector',
    control: 'checkbox',
},
  1. Run faust blockset script to build modified block.
  2. Add modified block to some page and try to view the page on the front end. Or simply run GraphQL query in the GraphiGL IDE.

Additional context

No response

@faustwp/core Version

3.0.1

@faustwp/cli Version

3.0.1

FaustWP Plugin Version

1.3.1

WordPress Version

6.5.2

Additional environment details

"@apollo/client": "^3.10.4",
"@faustwp/blocks": "^4.0.0",
"@wordpress/scripts": "^27.7.0",
"@faustwp/block-editor-utils": "^0.2.0",
"@wordpress/base-styles": "^4.49.0",
"@wordpress/block-library": "^8.35.0",
"@wordpress/style-engine": "^1.41.0",

Please confirm that you have searched existing issues in the repo.

  • Yes
@theodesp theodesp added the needs: reproduction This issue needs to be reproduced independently label May 31, 2024
@theodesp
Copy link
Member

theodesp commented May 31, 2024

Hey @jan-clockworkwp. Thank you for the report. I followed the steps you mentioned above, but I was able to query the new boolean field so I wasn't able to reproduce this issue in my setup.

Maybe this is related to this issue: wpengine/wp-graphql-content-blocks#238

@ChrisWiegman ChrisWiegman self-assigned this May 31, 2024
@ChrisWiegman
Copy link
Contributor

I do believe this is related to wpengine/wp-graphql-content-blocks#238 as @theodesp indicates above. I will do some investigation and try to reproduce.

@ChrisWiegman ChrisWiegman removed their assignment Jun 25, 2024
@theodesp
Copy link
Member

@jan-clockworkwp

https://github.com/wpengine/wp-graphql-content-blocks/releases/tag/v4.0.1

Should contain a fix for this issue. Please verify that it works and I can close this issue.

@theodesp theodesp added needs: author response Pending information from the author and removed needs: reproduction This issue needs to be reproduced independently labels Jun 25, 2024
@jan-clockworkwp
Copy link
Author

Well done @theodesp, both radio and checkbox controls are working now. I have just one comment that probably an update in the Faust official docs is needed. Let me explain why. In the official docs, the section Form Control Reference List, RadioControl is saying it should be of type boolean. It works okay that way, but I can't see the reason for using radio buttons for true/false over the CheckBoxControl. If string values are used for RadioControl in the options list, the attribute type needs to be changed to 'string' so they and default values work properly. According to this, it would make much more sense in the official docs to say that RadioControl should be of type string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: author response Pending information from the author
Projects
None yet
Development

No branches or pull requests

3 participants