Skip to content

Instantly share code, notes, and snippets.

@zetavg
Created July 31, 2016 16:12
Show Gist options
  • Select an option

  • Save zetavg/512bc7a50155248264f2b9dcf9b94cdd to your computer and use it in GitHub Desktop.

Select an option

Save zetavg/512bc7a50155248264f2b9dcf9b94cdd to your computer and use it in GitHub Desktop.

Q: 可以做到權限管理嗎?

A: 目前看起來可以,配合 OAuth access token 驗證使用者身份、只授權某些使用者做某些操作、根據使用者回傳 scoped resources、使用者只能編輯自己的文章⋯⋯之類的機制看起來都做得出來。

Q: Relay Connection 的 Edge,感覺實作上可以用 node id 來做,但為何官方 guide 不直接說「可以用 id 喔」,是什麼情況不能用 id 或不建議用 id 嗎?

A:

Q: 好像沒辦法做出 filter resources 的功能?

A:

Q: Relay 的 pagination 是使用 cursor,而非傳統的 page=xxx&per_page=xxx 分頁法,好處之一是避免 resources 一直在被更動的時候,造成分頁混亂。但目前發現 graphql-relay-ruby 竟然是直接用 offset 來當 curser,好像就失去 curser 的意義了。

@tomchentw
Copy link

tomchentw commented Sep 1, 2016

Q: 好像沒辦法做出 filter resources 的功能?

不是有 query parameter? 或是放在另一個 query 下,如 deletedPosts ?

Q: Relay 的 pagination 是使用 cursor

我(看完文件後)的想法是,cursor 是一個 base64 string 並沒有限制你要存什麼資料在其中,所以要用 offset + page 也 ok ,但也很容易改成其他的實作,因為對 user 而言都是透明的。

@zetavg
Copy link
Author

zetavg commented Sep 13, 2016

新的理解:

Q: 好像沒辦法做出 filter resources 的功能?

感覺放在另一個 query 下比較好,優點:

  1. 用「行為」而非「實作」來定義 filter,例如 "popularPosts" 優於 "commentsCount > 10 OR likesCount > 20 OR views > 1000"
  2. 開始使用 mutation 之後,需要定義一個 mutation 做下去之後,每個 connections 會如何改變?例如 createPost,會把剛剛 created 的 post prepend 到 latestPosts、append 到 myPosts (created_at: asc)。如果用 query parameter 好像會造成無法窮舉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment