GraphQL plugin cung cấp nhiều nhóm API giúp lập trình viên và AI assistant khám phá hệ thống, đọc mô tả REST API, đọc schema giao diện, event, Ezy Function, template parameters, entity class và tải các SQL script đang được kích hoạt.

Hướng dẫn truy cập

Để truy cập các API do GraphQL plugin cung cấp, quản trị viên đăng nhập vào trang quản trị EzyPlatform, sau đó mở menu GraphQL ở thanh điều hướng bên trái và chọn mục Các loại API., ví dụ như ảnh bên dưới.
0.png

Giải thích các loại API

Tại trang Các loại API, hệ thống hiển thị danh sách các nhóm API được chia theo 2 phạm vi chính:
  • admin: schema/API của admin runtime.
  • web: schema/API của web runtime, được admin proxy sang web management API bằng access token quản trị.

Swagger

Swagger API trả về OpenAPI YAML cho REST API đã được hệ thống phát hiện.
Phạm viEndpointContent-TypeMô tả
AdminGET /api/v1/rest/admin/swagger.yamlapplication/x-yamlTrả Swagger YAML của admin REST API
Web qua adminGET /api/v1/rest/web/swagger.yamlapplication/x-yamlAdmin proxy sang web runtime để lấy Swagger YAML
Web publicGET /api/v1/rest/swagger.yamlapplication/x-yamlTrả Swagger YAML của web runtime nếu bật cấu hình REST API docs
Web managementGET /management/api/v1/rest/swagger.yamlapplication/x-yamlEndpoint management nội bộ của web runtime
Trang Swagger UI:
Phạm viEndpointMô tả
AdminGET /rest/swagger/{target}Mở Swagger UI theo target, ví dụ admin hoặc web
WebGET /rest/swaggerMở Swagger UI của web nếu REST API docs đang bật
Lưu ý: web public Swagger phụ thuộc setting enable_rest_api_docs. Nếu tắt, endpoint public trả 404.

Model Context Protocol Server

MCP server được cung cấp tại:
GET /mcp
POST /mcp
GET /mcp trả metadata cơ bản:
{
  "name": "EzyPlatform GraphQL MCP",
  "protocolVersion": "2025-11-25",
  "endpoint": "/graphql/mcp",
  "methods": [
    "initialize",
    "notifications/initialized",
    "ping",
    "tools/list",
    "tools/call",
    "resources/list",
    "resources/read"
  ]
}
POST /mcp dùng JSON-RPC 2.0:
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "get_admin_swagger",
    "arguments": {}
  }
}
MCP server hỗ trợ:
MethodMô tả
initializeKhởi tạo MCP session, trả protocol version, capabilities và server info
notifications/initializedNhận notification sau khi client initialized
pingKiểm tra kết nối
tools/listLiệt kê tools
tools/callGọi một tool theo namearguments
resources/listLiệt kê resources
resources/readĐọc nội dung resource
Các tool chính:
ToolArgumentsMô tả
pingoptional messageKiểm tra MCP tool call
get_admin_swaggernoneLấy Swagger YAML của admin
get_web_swaggernoneLấy Swagger YAML của web
get_admin_view_schemanoneLấy toàn bộ admin view schema
get_admin_view_schema_by_uriviewUriLấy admin view schema theo URI
get_web_view_schemanoneLấy toàn bộ web view schema
get_web_view_schema_by_uriviewUriLấy web view schema theo URI
get_admin_event_schemanoneLấy toàn bộ admin event schema
get_admin_event_schema_by_nameeventNameLấy admin event schema theo tên event
get_web_event_schemanoneLấy toàn bộ web event schema
get_web_event_schema_by_nameeventNameLấy web event schema theo tên event
get_admin_ezy_function_schemanoneLấy schema Ezy Function của admin
get_web_ezy_function_schemanoneLấy schema Ezy Function của web
get_admin_class_schemaclassNamesLấy schema class trong admin runtime
get_web_class_schemaclassNamesLấy schema class trong web runtime
get_admin_entity_class_schemanoneLấy schema entity class của admin
get_admin_template_parameters_schemanoneLấy toàn bộ template parameters schema
get_admin_template_parameters_schema_by_type_and_nametemplateType, templateNameLấy template parameters schema cụ thể
get_sql_scriptsnoneLấy nội dung SQL scripts

View Schemas

View schema mô tả các view đã đăng ký trong runtime.
Phạm viEndpointQueryMô tả
AdminGET /api/v1/schemas/admin/viewnoneTrả map toàn bộ admin view schema, key là viewUri
AdminGET /api/v1/schemas/admin/view/by-uriviewUriTrả schema của một admin view
Web qua adminGET /api/v1/schemas/web/viewnoneTrả map toàn bộ web view schema
Web qua adminGET /api/v1/schemas/web/view/by-uriviewUriTrả schema của một web view
Web managementGET /management/api/v1/schemas/viewnoneEndpoint management của web runtime
Web managementGET /management/api/v1/schemas/view/by-uriviewUriEndpoint management lấy schema theo URI
Nếu không tìm thấy schema theo URI, API trả 404.

Event Schemas

Event schema mô tả các event mà runtime có thể xử lý.
Phạm viEndpointQueryMô tả
AdminGET /api/v1/schemas/admin/eventnoneTrả map toàn bộ admin event schema
AdminGET /api/v1/schemas/admin/event/by-nameeventNameTrả schema của một admin event
Web qua adminGET /api/v1/schemas/web/eventnoneTrả map toàn bộ web event schema
Web qua adminGET /api/v1/schemas/web/event/by-nameeventNameTrả schema của một web event
Web managementGET /management/api/v1/schemas/eventnoneEndpoint management của web runtime
Web managementGET /management/api/v1/schemas/event/by-nameeventNameEndpoint management lấy event schema theo tên
Nếu không tìm thấy event theo tên, API trả 404.

Ezy Function Schemas

Ezy Function schema là một nhóm đặc biệt của event schema, được lọc từ các event có prefix Ezy Function. Key trả về là tên function sau khi bỏ prefix.
Phạm viEndpointMô tả
AdminGET /api/v1/schemas/admin/ezy-functionTrả toàn bộ admin Ezy Function schema
Web qua adminGET /api/v1/schemas/web/ezy-functionTrả toàn bộ web Ezy Function schema
Web managementGET /management/api/v1/schemas/ezy-functionEndpoint management của web runtime

Template Parameters Schemas

Template parameters schema mô tả các tham số mà template cần nhận.
Phạm viEndpointMô tả
AdminGET /api/v1/schemas/admin/template-parametersTrả toàn bộ template parameters schema theo cấu trúc templateType -> templateName -> schema
Qua MCP có thể lấy schema cụ thể bằng tool:
{
  "name": "get_admin_template_parameters_schema_by_type_and_name",
  "arguments": {
    "templateType": "exampleType",
    "templateName": "exampleName"
  }
}

Entity Class Schemas

Entity class schema mô tả các JPA entity class được scan trong admin runtime.
Phạm viEndpointMô tả
AdminGET /api/v1/schemas/admin/entity-classTrả danh sách entity class schema, sắp xếp theo tableName
Mỗi item có dạng:
{
  "tableName": "table_name",
  "entityClass": "com.example.EntityClass",
  "idClass": "java.lang.Long"
}

Class Schemas

Class schema mô tả field, read method và enum value của các class được yêu cầu.
Phạm viEndpointQueryMô tả
AdminGET /api/v1/schemas/admin/classesclassNamesTrả schema của các class trong admin runtime
Web qua adminGET /api/v1/schemas/web/classesclassNamesTrả schema của các class trong web runtime
Web managementGET /management/api/v1/schemas/classesclassNamesEndpoint management của web runtime
Ví dụ:
GET /api/v1/schemas/admin/classes?classNames=com.example.User,com.example.Post
API chỉ trả schema cho class load được. Class không tồn tại hoặc không phù hợp sẽ bị bỏ qua.

Các mã SQL

SQL scripts API trả nội dung SQL tổng hợp từ:
  • script files của admin;
  • SQL script files trong các project/module đang active.
    Phạm viEndpointContent-TypeMô tả
    AdminGET /api/v1/sql-scriptstext/plainTải file sql-scripts.sql
    MCPget_sql_scriptstext contentTrả nội dung SQL scripts qua MCP tool
Phạm viEndpointContent-TypeMô tả
AdminGET /api/v1/sql-scriptstext/plainTải file sql-scripts.sql
MCPget_sql_scriptstext contentTrả nội dung SQL scripts qua MCP tool
Lưu ý: API này không sinh migration mới. Nó chỉ ghép nội dung các file SQL script hiện có thành một stream/file tải về.