-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
์น๊ตฌ๊ฐ ๋ฑ๋กํ ๊ธ๋ง ํผ๋์ ๋จ๊ฒ ํด์ผ ํ๊ธฐ ๋๋ฌธ์ ์น๊ตฌ์ ๋ํด์๋ง ์ ํผ๋๊ฐ ๋จ๋๋ก ์ค์
- Loading branch information
1 parent
a4a64fb
commit d68b38a
Showing
8 changed files
with
66 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,8 +48,8 @@ const GET_FEEDS = gql` | |
`; | ||
|
||
const FEEDS_SUBSCRIPTION = gql` | ||
subscription subscribeFeed { | ||
feeds { | ||
subscription subscribeFeed($userEmail: String!) { | ||
feeds(userEmail: $userEmail) { | ||
cursor | ||
feedItems { | ||
searchUser { | ||
|
@@ -117,7 +117,8 @@ const FeedList = () => { | |
const { data: value } = await fetchMore({ | ||
variables: { | ||
first: OFFSET, | ||
currentCursor: data && data.feeds ? data.feeds.cursor : '' | ||
currentCursor: | ||
data && data.feeds ? data.feeds.cursor : '9999-12-31T09:29:26.050Z' | ||
}, | ||
updateQuery: (prev, { fetchMoreResult }) => { | ||
if ( | ||
|
@@ -151,7 +152,7 @@ const FeedList = () => { | |
const subscribeToNewComments = () => { | ||
return subscribeToMore({ | ||
document: FEEDS_SUBSCRIPTION, | ||
variables: {}, | ||
variables: { userEmail: '[email protected]' }, | ||
updateQuery: (prev, { subscriptionData }) => { | ||
if (!subscriptionData.data) return prev; | ||
const { data: newFeeds } = subscriptionData; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import { Options } from 'graphql-yoga'; | |
import config from './utils/config'; | ||
import app from './app'; | ||
import './db'; | ||
import { decodeJWT } from './utils/jwt'; | ||
|
||
const PORT: string | number = config.port; | ||
const ENDPOINT: string = '/graphql'; | ||
|
@@ -17,7 +18,19 @@ const appOptions: Options = { | |
port: PORT, | ||
endpoint: ENDPOINT, | ||
playground: PLAYGROUND, | ||
cors: corsOptions | ||
cors: corsOptions, | ||
subscriptions: { | ||
onConnect: (connectionParams, webSocket, context) => { | ||
console.log('connection'); | ||
const token = context.request.headers.cookie | ||
.split(';') | ||
.filter(e => e.startsWith('token='))[0] | ||
.split('token=')[1]; | ||
const { email } = decodeJWT(token); | ||
// const email = '[email protected]'; | ||
return { email }; | ||
} | ||
} | ||
}; | ||
|
||
const handleStart = () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters