ปัญหาที่พบบ่อย
ปัญหาที่พบบ่อยการจำลองการอัปเดตเส้นทาง GraphQL Endpoint ผ่าน Hooks

การจำลองการอัปเดตเส้นทาง GraphQL Endpoint ผ่าน Hooks

หากคุณพบปัญหาบางอย่าง เช่น:

...และคุณได้ดำเนินการอย่างใดอย่างหนึ่งต่อไปนี้ใน Gato GraphQL:

  • อัปเดตเส้นทางของ GraphQL Single Endpoint
  • อัปเดต base slug ของ Custom Endpoints หรือ Persisted Queries
  • ปิดใช้งาน endpoint ใดๆ (โดยการปิดใช้งานโมดูลที่เกี่ยวข้อง)

...คุณต้องใช้การแก้ไขเดียวกันผ่าน hook เพื่อหลีกเลี่ยงความขัดแย้ง

Hooks

หากคุณแก้ไขเส้นทางของ public endpoint ใดๆ ผ่านการตั้งค่าของปลั๊กอิน คุณต้องใช้การแก้ไขเดียวกันผ่าน hook:

  • gatographql:before_app_is_loaded:graphql_endpoint_paths

ในทำนองเดียวกัน หากคุณปิดใช้งาน public endpoint Module ใดๆ คุณต้องลบเส้นทางที่เกี่ยวข้องออกผ่าน hook

ตัวอย่าง

หากคุณเปลี่ยนเส้นทาง 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',
    );
  }
);