Skip to content
This repository was archived by the owner on Sep 10, 2026. It is now read-only.

bug: When start new query in admin, do not show error message - #237

Merged
markkelnar merged 9 commits into
wp-graphql:mainfrom
markkelnar:bug/fix-admin-editor-error-message
Aug 3, 2023
Merged

markkelnar merged 9 commits into
wp-graphql:mainfrom
markkelnar:bug/fix-admin-editor-error-message

Conversation

@markkelnar

@markkelnar markkelnar commented Jul 26, 2023 •

Copy link
Copy Markdown
Contributor

When creating new 'saved document' in admin editor, do not show the error message in red 'Something is wrong with the form data'. This message happens for a new post and the 'auto-draft' triggers the save_post_query action, which is trying to validate the query document form data. But that _POST data doesn't have data yet.

For the new saved query in auto-draft, be more deliberate about form data validation. Put more accurate error message if something is missing/invalid.

@markkelnar
markkelnar requested a review from jasonbahl July 28, 2023 19:33
@jasonbahl

jasonbahl commented Aug 1, 2023 •

Copy link
Copy Markdown
Collaborator

@markkelnar so it looks like the original issue of not showing "something is wrong with the form data" is gone, but it still seems like something is wrong.

If I try and save a document with an invalid document (like just a string saying "invalid document") I get an admin error that states:

Did not save invalid graphql query string "invalid document"

CleanShot 2023-08-01 at 12 25 07@2x

However, even though the error states it did not save, it actually is saved and I can see the document in the list of GraphQL Documents:

CleanShot 2023-08-01 at 12 25 24@2x

perhaps the save_post hook is the wrong hook?

https://wordpress.stackexchange.com/questions/42013/prevent-post-from-being-published-if-custom-fields-not-filled#answer-42178

As m0r7if3r pointed out, there is no way of preventing a post from being published using the save_post hook, since the by the time that hook is fired, the post is already saved.

@jasonbahl jasonbahl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markkelnar
markkelnar requested a review from jasonbahl August 3, 2023 14:34
@jasonbahl

jasonbahl commented Aug 3, 2023 •

Copy link
Copy Markdown
Collaborator

@markkelnar when testing, we can still "publish" the document without a valid document.

CleanShot 2023-08-03 at 08 48 57

Since the current issue was specifically targeting the error messaging, I'll create another issue to follow-up on tightening up the behavior around publishing.

@markkelnar
markkelnar merged commit 927c93d into wp-graphql:main Aug 3, 2023
@markkelnar
markkelnar deleted the bug/fix-admin-editor-error-message branch August 3, 2023 15:15
@jasonbahl

Copy link
Copy Markdown
Collaborator

related: #243

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants