diff --git a/src/graphql/post.ts b/src/graphql/post.ts index 57ba1c5..0cba179 100644 --- a/src/graphql/post.ts +++ b/src/graphql/post.ts @@ -646,10 +646,10 @@ export const resolvers: IResolvers = { }, Mutation: { writePost: async (parent: any, args, ctx) => { - return await postService.write(args, ctx.cookies); + return await postService.write(args, ctx.cookies, ctx.ip); }, editPost: async (parent: any, args, ctx) => { - return await postService.edit(args, ctx.cookies); + return await postService.edit(args, ctx.cookies, ctx.ip); }, removePost: async (parent: any, args, ctx) => { const { id } = args as { id: string }; diff --git a/src/services/postService.ts b/src/services/postService.ts index 37c7ef4..8b0edfa 100644 --- a/src/services/postService.ts +++ b/src/services/postService.ts @@ -322,7 +322,7 @@ const postService = { } }, - async write(args: WritePostArgs, cookies: Cookies) { + async write(args: WritePostArgs, cookies: Cookies, ip: string) { const WRITE_POST_MUTATION = ` mutation WritePost($input: WritePostInput!) { writePost(input: $input) { @@ -355,6 +355,7 @@ const postService = { headers: { 'Content-Type': 'application/json', authorization: `Bearer ${accessToken}`, + 'X-Forwarded-For': ip, }, } ); @@ -364,7 +365,7 @@ const postService = { console.log('write post error', error); } }, - async edit(args: EditPostArgs, cookies: Cookies) { + async edit(args: EditPostArgs, cookies: Cookies, ip: string) { const EDIT_POST_MUTATION = ` mutation EditPost($input: EditPostInput!) { editPost(input: $input) { @@ -396,6 +397,7 @@ const postService = { headers: { 'Content-Type': 'application/json', authorization: `Bearer ${accessToken}`, + 'X-Forwarded-For': ip, }, } );