When using a WPGraphQL mutation to update/create a taxonomy term that contains an apostrophe, WPGraphQL is saving the slashes to the database. This is not consistent with other core behaviors for creating/inserting terms (Admin Dashboard, WP REST API)
Steps to reproduce:
As an authenticated user, execute the following mutation:
mutation {
createTag( input: { name: "What's up!" } ) {
tag {
name
}
}
}
This will give us the tag name What\\'s up! in the response.

And if we look at the database we see the raw value What\'s up! was stored.

Expectation
I expect the value in the database to not be stored with the slash, as seen when doing Tag mutations with the WP REST API.
If we create a term using the WP REST API
This gives us the expected name in the response:

And stores as expected in the database:

Quick Solution
Until this is fixed in WPGraphQL, users should be able to use the following filter:
add_action('graphql_term_object_insert_term_args', 'clean_tag_name');
function clean_tag_name($args) {
$args['name'] = stripslashes($args['name']);
$args['description'] = stripslashes($args['description']);
$args['slug'] = stripslashes($args['slug']);
return $args;
}
When using a WPGraphQL mutation to update/create a taxonomy term that contains an apostrophe, WPGraphQL is saving the slashes to the database. This is not consistent with other core behaviors for creating/inserting terms (Admin Dashboard, WP REST API)
Steps to reproduce:
As an authenticated user, execute the following mutation:
This will give us the tag name
What\\'s up!in the response.And if we look at the database we see the raw value
What\'s up!was stored.Expectation
If we create a term using the WP REST API
This gives us the expected name in the response:
And stores as expected in the database:
Quick Solution
Until this is fixed in WPGraphQL, users should be able to use the following filter: