Example of changing from simple subscriptions to (equivalent) custom subscriptions
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 28/100
- Issue 類型
- 文件
- 描述清晰度
- 需要釐清
- 活躍度
- 停滯
- 技術堆疊
- graphql, javascript
研究方向
未指定檔案、測試或文件入口點。首先找到 subscriptions 文件區域,並確定此範例應放在哪裡;完成標準是加入從簡單到自訂 subscription 的範例,並實現 issue 中描述的等效行為。
由索引模型根據 Issue 內容生成。
描述
// MySubscriptionPlugin.js
const base64 = (str) => Buffer.from(String(str)).toString("base64");
const nodeIdFromDbNode = (dbNode) => base64(JSON.stringify(dbNode));
const { makeExtendSchemaPlugin, gql, embed } = require("graphile-utils");
const listenTopic = async (args, _context, _resolveInfo) => {
const authCheckPassed = true; // TODO: implement your auth checks here
if (authCheckPassed) {
return `postgraphile:${args.topic}`;
} else {
throw new Error("You're not allowed to subscribe to this topic");
}
};
function filterFn(payload, variables, context, info) {
return true;
}
const MyPlugin = makeExtendSchemaPlugin((build) => {
const { extend, newWithHooks, pgSql: sql, $$isQuery, resolveNode } = build;
return {
typeDefs: gql`
type ListenPayload {
query: Query
relatedNode: Node
relatedNodeId: ID
}
extend type Subscription {
"""
Listen for any changes within the Platform with filter functionality
"""
listen(topic: String!, filter: String): ListenPayload @pgSubscription(
topic: ${embed(listenTopic)}
)
}
`,
resolvers: {
Subscription: { listen: { resolve: (event) => event } },
ListenPayload: {
query: () => $$isQuery,
relatedNodeId: (event) => nodeIdFromDbNode(event.__node__),
async relatedNode(event, _args, resolveContext, resolveInfo) {
const {
getDataFromParsedResolveInfoFragment,
} = resolveInfo.graphile.fieldContext;
return resolveNode(
nodeIdFromDbNode(event.__node__),
build,
{ getDataFromParsedResolveInfoFragment },
{},
resolveContext,
resolveInfo
);
},
},
},
};
});
module.exports = MyPlugin;
- 主要語言
- SCSS
- 星號
- 27
- 分支
- 124
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
graphile/graphile.github.io 的其他 Issue
-
help wanted quick
難度 2/5 1-3 小時 新手友好度 38/100
graphile/graphile.github.io#401 · 1 則留言 · 1 個 reaction ·
-
website: Update details on homepage and sponsor page可能重新可做 @jemgillam 於 1119 天前認領,目前沒有進行中的 PR。 未關閉quick
graphile/graphile.github.io#399 · 4 則留言 · 已指派 1 人 ·
-
sponsor page: New wording around Grafast needed!可能重新可做 @jemgillam 於 1149 天前認領,目前沒有進行中的 PR。 未關閉
graphile/graphile.github.io#393 · 1 個 reaction · 已指派 1 人 ·
-
難度 2/5 1-3 小時 新手友好度 38/100
graphile/graphile.github.io#341 · 1 個 reaction ·
-
難度 2/5 1-3 小時 新手友好度 25/100
graphile/graphile.github.io#280 · 2 則留言 · 5 個 reaction ·
查看 graphile/graphile.github.io 的全部 Issue
相似的 Issue
-
agent/scanner bug stage/010-actionable
難度 1/5 1 小時以內 新手友好度 88/100
torch-spyre/spyre-inference#1812 ·
維護者通常 1 天內回覆
-
sync-en
難度 1/5 1 小時以內 新手友好度 82/100
維護者通常 1 天內回覆
-
[oblt-aw][autodoc] Update autodoc routing docs for relative in-repo lock uses可能已有人在做 @github-actions 今天認領。 未關閉
難度 1/5 1-3 小時 新手友好度 87/100
維護者通常 1 天內回覆
-
[Enhancement] platform-engineer: a definition change does not re-render running Applications; say how to roll it out可能已有人在做 @anoop2811 今天認領。 未關閉needs-triage type/enhancement
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 88/100
cloudflare/workers-sdk#17189 ·
維護者通常 1 天內回覆