Common Issues
Common IssuesPolylang is misbehaving

Polylang is misbehaving

When using the Polylang extension, and you notice the following issues when fetching data using GraphQL from a public endpoint:

  • Polylang won't properly detect the current language for GraphQL requests
  • Language-specific content won't be filtered correctly
  • You get content in the wrong language or no content at all

...and you have done either of the following in Gato GraphQL:

  • Updated the path of the GraphQL Single Endpoint
  • Updated the base slug of Custom Endpoints or Persisted Queries
  • Disabled any endpoint (by disabling the corresponding module)

...then you must apply the same modification via a hook, to avoid the conflict.

Why this happens

There is a timing conflict between Polylang's initialization and Gato GraphQL's service container setup.

Polylang sets the pll_model and pll_context filters during its initialization process. Because Gato GraphQL is not yet initialized, it can't retrieve the correct endpoint paths from the database, as to determine if the request is coming from a GraphQL endpoint and override the model and context with the correct ones (PLL_Admin_Model and PLL_Admin respectively).

Workaround

When Polylang sets the pll_model and pll_context filters, Gato GraphQL assumes the default paths for the GraphQL endpoints.

Then, if you modify the path of any public endpoint via the plugin Settings, you must apply the same modification via hook.

Read guide Replicating GraphQL endpoint path updates via hooks for the solution.