자주 발생하는 문제
자주 발생하는 문제훅을 통한 GraphQL 엔드포인트 경로 업데이트 복제

훅을 통한 GraphQL 엔드포인트 경로 업데이트 복제

다음과 같은 문제가 발생하는 경우:

...그리고 Gato GraphQL에서 다음 중 하나를 수행한 경우:

  • GraphQL Single Endpoint의 경로를 업데이트했습니다
  • Custom Endpoints 또는 Persisted Queries의 기본 슬러그를 업데이트했습니다
  • 해당 모듈을 비활성화하여 엔드포인트를 비활성화했습니다

...그렇다면 충돌을 방지하기 위해 훅을 통해 동일한 수정을 적용해야 합니다.

플러그인 설정에서 공개 엔드포인트의 경로를 수정한 경우, 훅을 통해 동일한 수정을 적용해야 합니다:

  • gatographql:before_app_is_loaded:graphql_endpoint_paths

마찬가지로, 공개 엔드포인트 모듈을 비활성화한 경우에는 훅을 사용하여 해당 경로를 제거해야 합니다.

예시

플러그인 설정에서 Single Endpoint 경로를 graphql에서 api/graphql로 변경한 경우:

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
    );
  }
);

Single Endpoint 모듈을 비활성화한 경우:

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',
    );
  }
);