Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

メッセージの通知 subscription #200

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

takumihara
Copy link
Collaborator

目的

  • メッセージ作成時に、相手方にwebsocket通信で通知を送る
  • バリデーションの追加
  • tokenのparseがwsで今まで出来てなかったので、それの実装
  • indexつけるのがidなのでmessageをidでソートするよう変更

参考

Subscriptions in Apollo Server - Apollo GraphQL Docs

@takumihara takumihara self-assigned this Sep 1, 2022
orderBy: {
createdAt: "asc",
},
orderBy: { id: "asc" },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createdAtが直感的かなと思ったのですが、変更した理由はなんです?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indexつけるのidになるので、そっちの方が効率良いかと思いました!(ですよね?) auto incrementなので、これで順序変わることはないはずですし!

Comment on lines +189 to +192
const validateOwnership = (profileId: number, post: Post) => {
if (profileId != post.driverId && profileId != post.navigatorId) {
throw new Error("no right to see messages");
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good!

@@ -62,3 +62,36 @@ export const context = ({ req }: { req: Request }): Context => {
},
};
};

export const contextForWs = async (ctx: any, msg: any, args: any) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wsって何の略ですか?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

web socket ですかね。

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ですです

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants