Common Issues
Common IssuesReplicating GraphQL endpoint path updates via hooks

Replicating GraphQL endpoint path updates via hooks

If you experience certain issues, such as:

...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.

Hooks

If you modify the path of any public endpoint via the plugin Settings, you must apply the same modification via hook:

  • gatographql:before_app_is_loaded:graphql_endpoint_paths

Similarly, if you disable any public endpoint Module, you must remove the corresponding path via the hook.

Examples

If you've changed the Single Endpoint path from graphql to api/graphql in the plugin Settings:

add_filter(
  'gatographql:before_app_is_loaded:graphql_endpoint_paths',
  function(array $endpointPaths): array {
    // Replace the default 'graphql' path with your custom path
    return array_map(
      fn ($path) => $path === 'graphql' ? 'api/graphql' : $path,
      $endpointPaths
    );
  }
);

If you've disabled the Single Endpoint module:

add_filter(
  'gatographql:before_app_is_loaded:graphql_endpoint_paths',
  function(array $endpointPaths): array {
    // Remove the 'graphql' path since the module is disabled
    return array_filter(
      $endpointPaths,
      fn ($path) => $path !== 'graphql',
    );
  }
);