X-GraphQL-Event-Stream for being notified that the GraphQL schema has updated
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- graphql, javascript
- Lĩnh vực
- api, backend-api-design
Hướng nghiên cứu
Bắt đầu bằng việc xem xét pull request được liên kết của GraphiQL.app, phần triển khai của Altair và tài liệu tham chiếu của PostGraphile để so sánh cách đề xuất X-GraphQL-Event-Stream được xử lý. Công việc được coi là hoàn tất khi đạt được sự thống nhất về hành vi và đưa quyết định đó vào đặc tả GraphQL over HTTP.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Server-sent events are a perfect mechanism for informing a GraphQL client that the schema has been updated. They don't require the complexity of websockets, and they are uni-directional.
I'm proposing that when introspecting a GraphQL API, if the header X-GraphQL-Event-Stream is detected then interested clients should subscribe to the text/event-stream at that (relative or absolute) URL and when it receives the change event it should automatically re-introspect the GraphQL schema.
Not much code should be required to implement this, just something like:
// refreshSchema is a function you provide which triggers re-introspection
const streamUrl = response.headers["x-graphql-event-stream"];
if (streamUrl) {
const endpointUrl = new URL(endpoint);
const streamUrl = new URL(streamUrl, endpointUrl);
if (endpointUrl.host !== streamUrl.host) {
throw new Error(
`Stream and endpoint hosts don't match - '${streamUrl.host}' !== '${endpointUrl.host}'`
);
}
const eventSource = new EventSource(streamUrl);
eventSource.addEventListener("change", refreshSchema, false);
eventSource.addEventListener("open", () => { /* ... */ }, false);
eventSource.addEventListener("error", () => { /* ... */ }, false);
}
(You may want to throttle the refreshSchema method.)
This has been baked into PostGraphile for a while; I opened an implementation PR to @skevy's GraphiQL.app a good while ago; and @imolorhe has implemented it independently in Altair. Samuel wrote more about it here: https://sirmuel.design/a-better-graphql-developer-experience-with-x-graphql-event-stream-1256aef96f24. We'll probably be implementing it in the new version of GraphiQL too, once we have the plugin system in place.
What are your thoughts?
- Ngôn ngữ chính
- JavaScript
- Star
- 428
- Fork
- 70
- Merge trung bình
- 11 phút
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của graphql/graphql-over-http
-
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 25/100
graphql/graphql-over-http#446 · 3 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
graphql/graphql-over-http#415 ·
-
Persisted documents by default?Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
graphql/graphql-over-http#392 · 4 reaction ·
-
Clarification for `Accept: */*`Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
graphql/graphql-over-http#242 · 8 bình luận ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
graphql/graphql-over-http#216 · 15 bình luận · 1 reaction ·
Tất cả issue của graphql/graphql-over-http
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
feature request
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
openlayers/openlayers#17736 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
521xueweihan/HelloGitHub#4326 ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Mintplex-Labs/anything-llm#7133 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày