Open
Reported for: WPML GraphQL 1.0.0
Overview of the issue
When using GraphQL and utilizing a query similar to the following to retrieve Custom Post Types by slug, you will discover that it functions only for the posts in the default language:
query getArticlesByslug { article(id: "your-slug-goes-here", idType: SLUG) { title content } }
Workaround
Please, make sure of having a full backup of your site before proceeding.
- Open your theme’s functions.php file.
- Add this code:
add_filter('request', function($vars){ if ( is_graphql_http_request() && !empty($vars['name']) ) { $vars['suppress_filters'] = true; } return $vars; });
Just a note, this is not only for Custom Post Type but also for posts and pages.
Thank you for the clarification, Sebastien.
Yes, at the moment, I can not get posts or pages from a specific URI, only original language works
This workaround fixes SLUG issue, but not URI
Thank you for your report, Pavel. In that case, please open a chat in our support channel, in that way one of our specialists may be able to help you better.
Regards