wp-graphql-polylang icon indicating copy to clipboard operation
wp-graphql-polylang copied to clipboard

Does not work when called from PHP using `do_graphql_request()`

Open esamattis opened this issue 5 years ago • 0 comments

See https://github.com/wp-graphql/wp-graphql/issues/1021#issuecomment-555171653

Actually wp-graphql-polylang cannot work at all when called from PHP. That's because Polylang initializes itself into a specific mode which maybe be "admin", "frontend" or "rest" and now via wp-graphql-polylang "graphl" too. Once the intialization has been done it cannot changed anymore (at least to my knowledge).

So in wp-graphql-polylang I must tell it to go to the graphql mode as soon as possible. If it is too late Polylang will initialize into the frontend mode. This does happen before the init. The frontend mode would filter everything by the default language which is no good for a graphql api because you'll want to specify the language using the where-args so you can query posts in multiple languages if you want.

esamattis avatar Nov 18 '19 19:11 esamattis