diff --git a/package-lock.json b/package-lock.json index eeb5413..697d4cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { + "@apollo/sandbox": "^2.5.1", "@apollo/server": "^4.9.4", "@as-integrations/aws-lambda": "^3.1.0", "@graphql-tools/schema": "^9.0.10", @@ -78,6 +79,31 @@ "apollo-pbts": "bin/pbts" } }, + "node_modules/@apollo/sandbox": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@apollo/sandbox/-/sandbox-2.5.1.tgz", + "integrity": "sha512-3QMm0gAdNNOaJqw8k6ez4/pXROgs0jy2eCTJY26bv/eQEM+U/HajuLgQsM26dxt/mtxBLLO0B4wg11S/fFGchg==", + "dependencies": { + "@types/whatwg-mimetype": "^3.0.0", + "eventemitter3": "3.1.0", + "graphql-ws": "^5.9.0", + "subscriptions-transport-ws": "^0.11.0", + "whatwg-mimetype": "^3.0.0", + "zen-observable-ts": "^1.1.0" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17.0.0 || ^18.0.0", + "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0" + }, + "peerDependenciesMeta": { + "react": { + "optional": true + }, + "react-dom": { + "optional": true + } + } + }, "node_modules/@apollo/server": { "version": "4.9.4", "resolved": "https://registry.npmjs.org/@apollo/server/-/server-4.9.4.tgz", @@ -3183,6 +3209,11 @@ "integrity": "sha512-xfHdwa1FMJ082prjSJpoEI57GZITiQz10r3vEJCHa2khEFQjKy91aWKz6+zybzssCvXUwE1LQWgWVwZ4nYUvHQ==", "dev": true }, + "node_modules/@types/whatwg-mimetype": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/whatwg-mimetype/-/whatwg-mimetype-3.0.1.tgz", + "integrity": "sha512-dy1Os16KVaOyiwS237oURk7v0IGezg06FUlW//WcoAJMqrMSQlHNiYmZz06MgXdqE/uARd9h+sOm4AWRsJvUnQ==" + }, "node_modules/@types/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", @@ -3192,6 +3223,11 @@ "@types/node": "*" } }, + "node_modules/@types/zen-observable": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/@types/zen-observable/-/zen-observable-0.8.3.tgz", + "integrity": "sha512-fbF6oTd4sGGy0xjHPKAt+eS2CrxJ3+6gQ3FGcBoIJR2TLAyCkCyI8JqZNy+FeON0AhVgNJoUumVoZQjBFUqHkw==" + }, "node_modules/@webassemblyjs/ast": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", @@ -4036,6 +4072,11 @@ "@babel/core": "^7.4.0 || ^8.0.0-0 <8.0.0" } }, + "node_modules/backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha512-zj6Z6M7Eq+PBZ7PQxl5NT665MvJdAkzp0f60nAJ+sLaSCBPMwVak5ZegFbgVCzFcCJTKFoMizvM5Ld7+JrRJHA==" + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -5150,6 +5191,11 @@ "node": ">= 0.6" } }, + "node_modules/eventemitter3": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz", + "integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==" + }, "node_modules/execa": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", @@ -5895,6 +5941,17 @@ "graphql": "^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0" } }, + "node_modules/graphql-ws": { + "version": "5.14.2", + "resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.14.2.tgz", + "integrity": "sha512-LycmCwhZ+Op2GlHz4BZDsUYHKRiiUz+3r9wbhBATMETNlORQJAaFlAgTFoeRh6xQoQegwYwIylVD1Qns9/DA3w==", + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "graphql": ">=0.11 <=16" + } + }, "node_modules/has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -6481,6 +6538,11 @@ "whatwg-fetch": "^3.4.1" } }, + "node_modules/iterall": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.3.0.tgz", + "integrity": "sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg==" + }, "node_modules/jackspeak": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", @@ -8882,6 +8944,42 @@ "url": "https://github.com/sponsors/Borewit" } }, + "node_modules/subscriptions-transport-ws": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/subscriptions-transport-ws/-/subscriptions-transport-ws-0.11.0.tgz", + "integrity": "sha512-8D4C6DIH5tGiAIpp5I0wD/xRlNiZAPGHygzCe7VzyzUoxHtawzjNAY9SUTXU05/EY2NMY9/9GF0ycizkXr1CWQ==", + "deprecated": "The `subscriptions-transport-ws` package is no longer maintained. We recommend you use `graphql-ws` instead. For help migrating Apollo software to `graphql-ws`, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws For general help using `graphql-ws`, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md", + "dependencies": { + "backo2": "^1.0.2", + "eventemitter3": "^3.1.0", + "iterall": "^1.2.1", + "symbol-observable": "^1.0.4", + "ws": "^5.2.0 || ^6.0.0 || ^7.0.0" + }, + "peerDependencies": { + "graphql": "^15.7.2 || ^16.0.0" + } + }, + "node_modules/subscriptions-transport-ws/node_modules/ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "engines": { + "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -8905,6 +9003,14 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/symbol-observable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/tar-fs": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", @@ -10062,6 +10168,20 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "node_modules/zen-observable": { + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz", + "integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==" + }, + "node_modules/zen-observable-ts": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.1.0.tgz", + "integrity": "sha512-1h4zlLSqI2cRLPJUHJFL8bCWHhkpuXkF+dbGkRaWjgDIG26DmzyshUMrdV/rL3UnR+mhaX4fRq8LPouq0MYYIA==", + "dependencies": { + "@types/zen-observable": "0.8.3", + "zen-observable": "0.8.15" + } } }, "dependencies": { @@ -10100,6 +10220,19 @@ "long": "^4.0.0" } }, + "@apollo/sandbox": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/@apollo/sandbox/-/sandbox-2.5.1.tgz", + "integrity": "sha512-3QMm0gAdNNOaJqw8k6ez4/pXROgs0jy2eCTJY26bv/eQEM+U/HajuLgQsM26dxt/mtxBLLO0B4wg11S/fFGchg==", + "requires": { + "@types/whatwg-mimetype": "^3.0.0", + "eventemitter3": "3.1.0", + "graphql-ws": "^5.9.0", + "subscriptions-transport-ws": "^0.11.0", + "whatwg-mimetype": "^3.0.0", + "zen-observable-ts": "^1.1.0" + } + }, "@apollo/server": { "version": "4.9.4", "resolved": "https://registry.npmjs.org/@apollo/server/-/server-4.9.4.tgz", @@ -12368,6 +12501,11 @@ "integrity": "sha512-xfHdwa1FMJ082prjSJpoEI57GZITiQz10r3vEJCHa2khEFQjKy91aWKz6+zybzssCvXUwE1LQWgWVwZ4nYUvHQ==", "dev": true }, + "@types/whatwg-mimetype": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/whatwg-mimetype/-/whatwg-mimetype-3.0.1.tgz", + "integrity": "sha512-dy1Os16KVaOyiwS237oURk7v0IGezg06FUlW//WcoAJMqrMSQlHNiYmZz06MgXdqE/uARd9h+sOm4AWRsJvUnQ==" + }, "@types/yauzl": { "version": "2.10.0", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.10.0.tgz", @@ -12377,6 +12515,11 @@ "@types/node": "*" } }, + "@types/zen-observable": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/@types/zen-observable/-/zen-observable-0.8.3.tgz", + "integrity": "sha512-fbF6oTd4sGGy0xjHPKAt+eS2CrxJ3+6gQ3FGcBoIJR2TLAyCkCyI8JqZNy+FeON0AhVgNJoUumVoZQjBFUqHkw==" + }, "@webassemblyjs/ast": { "version": "1.11.6", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz", @@ -13045,6 +13188,11 @@ "@babel/helper-define-polyfill-provider": "^0.4.3" } }, + "backo2": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz", + "integrity": "sha512-zj6Z6M7Eq+PBZ7PQxl5NT665MvJdAkzp0f60nAJ+sLaSCBPMwVak5ZegFbgVCzFcCJTKFoMizvM5Ld7+JrRJHA==" + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", @@ -13901,6 +14049,11 @@ "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==" }, + "eventemitter3": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz", + "integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==" + }, "execa": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/execa/-/execa-0.7.0.tgz", @@ -14484,6 +14637,12 @@ "tslib": "^2.1.0" } }, + "graphql-ws": { + "version": "5.14.2", + "resolved": "https://registry.npmjs.org/graphql-ws/-/graphql-ws-5.14.2.tgz", + "integrity": "sha512-LycmCwhZ+Op2GlHz4BZDsUYHKRiiUz+3r9wbhBATMETNlORQJAaFlAgTFoeRh6xQoQegwYwIylVD1Qns9/DA3w==", + "requires": {} + }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", @@ -14928,6 +15087,11 @@ "whatwg-fetch": "^3.4.1" } }, + "iterall": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/iterall/-/iterall-1.3.0.tgz", + "integrity": "sha512-QZ9qOMdF+QLHxy1QIpUHUU1D5pS2CG2P69LF6L6CPjPYA/XMOmKV3PZpawHoAjHNyB0swdVTRxdYT4tbBbxqwg==" + }, "jackspeak": { "version": "2.3.6", "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.3.6.tgz", @@ -16778,6 +16942,26 @@ "peek-readable": "^4.1.0" } }, + "subscriptions-transport-ws": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/subscriptions-transport-ws/-/subscriptions-transport-ws-0.11.0.tgz", + "integrity": "sha512-8D4C6DIH5tGiAIpp5I0wD/xRlNiZAPGHygzCe7VzyzUoxHtawzjNAY9SUTXU05/EY2NMY9/9GF0ycizkXr1CWQ==", + "requires": { + "backo2": "^1.0.2", + "eventemitter3": "^3.1.0", + "iterall": "^1.2.1", + "symbol-observable": "^1.0.4", + "ws": "^5.2.0 || ^6.0.0 || ^7.0.0" + }, + "dependencies": { + "ws": { + "version": "7.5.9", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", + "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "requires": {} + } + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -16792,6 +16976,11 @@ "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", "dev": true }, + "symbol-observable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.2.0.tgz", + "integrity": "sha512-e900nM8RRtGhlV36KGEU9k65K3mPb1WV70OdjfxlG2EAuM1noi/E/BaW/uMhL7bPEssK8QV57vN3esixjUvcXQ==" + }, "tar-fs": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", @@ -17611,6 +17800,20 @@ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-1.0.0.tgz", "integrity": "sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==", "dev": true + }, + "zen-observable": { + "version": "0.8.15", + "resolved": "https://registry.npmjs.org/zen-observable/-/zen-observable-0.8.15.tgz", + "integrity": "sha512-PQ2PC7R9rslx84ndNBZB/Dkv8V8fZEpk83RLgXtYd0fwUgEjseMn1Dgajh2x6S8QbZAFa9p2qVCEuYZNgve0dQ==" + }, + "zen-observable-ts": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/zen-observable-ts/-/zen-observable-ts-1.1.0.tgz", + "integrity": "sha512-1h4zlLSqI2cRLPJUHJFL8bCWHhkpuXkF+dbGkRaWjgDIG26DmzyshUMrdV/rL3UnR+mhaX4fRq8LPouq0MYYIA==", + "requires": { + "@types/zen-observable": "0.8.3", + "zen-observable": "0.8.15" + } } } } diff --git a/package.json b/package.json index 553f8a0..586954d 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ }, "homepage": "https://github.com/HUNG-rushb/Images-Social-Server#readme", "dependencies": { + "@apollo/sandbox": "^2.5.1", "@apollo/server": "^4.9.4", "@as-integrations/aws-lambda": "^3.1.0", "@graphql-tools/schema": "^9.0.10", diff --git a/src/Type_Definitions/Comment_Comment.js b/src/Type_Definitions/Comment_Comment.js index 72d1514..55ff23b 100644 --- a/src/Type_Definitions/Comment_Comment.js +++ b/src/Type_Definitions/Comment_Comment.js @@ -10,7 +10,7 @@ const commentDefs = gql` createComment(data: CreateCommentInput!): Comment! deleteComment(data: DeleteCommentInput!): Comment! updateComment(data: UpdateCommentInput!): Comment! - voteCommand(data: VoteCommentInput!): Comment! + voteComment(data: VoteCommentInput!): Comment! } extend type Query { diff --git a/src/handler.js b/src/handler.js index 16967fd..d31c87b 100644 --- a/src/handler.js +++ b/src/handler.js @@ -1,11 +1,13 @@ // Apollo import { ApolloServer } from '@apollo/server'; -import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default'; +import { + ApolloServerPluginLandingPageLocalDefault, + ApolloServerPluginLandingPageProductionDefault +} from '@apollo/server/plugin/landingPage/default'; import { startServerAndCreateLambdaHandler, handlers, } from '@as-integrations/aws-lambda'; - // Prisma import { prisma } from './prisma/database.js'; @@ -36,7 +38,7 @@ const server = new ApolloServer({ return { prisma }; }, plugins: [ - ApolloServerPluginLandingPageLocalDefault, + ApolloServerPluginLandingPageProductionDefault, ...(parseInt(process.env.IS_LOGGING) ? [loggingPlugin] : []), ], logger: console, diff --git a/src/index.js b/src/index.js index f10f8f5..53becda 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,10 @@ // Apollo import { ApolloServer } from '@apollo/server'; -import { ApolloServerPluginLandingPageLocalDefault } from '@apollo/server/plugin/landingPage/default'; import { startStandaloneServer } from '@apollo/server/standalone'; +import { + ApolloServerPluginLandingPageLocalDefault, + ApolloServerPluginLandingPageProductionDefault +} from '@apollo/server/plugin/landingPage/default'; // Prisma import { prisma } from './prisma/database.js'; @@ -35,7 +38,7 @@ const server = new ApolloServer({ credentials: true, // <- enable CORS response for requests with credentials (cookies, http authentication) }, plugins: [ - ApolloServerPluginLandingPageLocalDefault, + ApolloServerPluginLandingPageProductionDefault, ...(parseInt(process.env.IS_LOGGING) ? [loggingPlugin] : []), ], logger: console, diff --git a/src/resolvers/Mutation/comment.js b/src/resolvers/Mutation/comment.js index b98d22f..ba32fe5 100644 --- a/src/resolvers/Mutation/comment.js +++ b/src/resolvers/Mutation/comment.js @@ -45,6 +45,7 @@ const commentMutation = { return comment; }, + updateComment: async (parent, args, info) => { return await prisma.comment.update({ where: { @@ -63,7 +64,7 @@ const commentMutation = { * @param {*} info * @returns */ - voteCommand: async (parent, args, info) => { + voteComment: async (parent, args, info) => { const { action, commentId } = args.data; const existedComment = await prisma.comment.findUnique({ diff --git a/src/resolvers/Query/STORY.js b/src/resolvers/Query/STORY.js index 4995c7f..4e3821d 100644 --- a/src/resolvers/Query/STORY.js +++ b/src/resolvers/Query/STORY.js @@ -58,7 +58,14 @@ const storyQuery = { }, }; }, - storyInfo: async (parent, args, { prisma }, info) => { + + /** + * @param {*} parent + * @param {{data: {storyId: string}}} args + * @param {*} info + * @returns + */ + storyInfo: async (parent, args, info) => { return await prisma.story.findUnique({ where: { id: args.data.storyId, diff --git a/src/resolvers/Query/TAG.js b/src/resolvers/Query/TAG.js index 4a0103a..77fe202 100644 --- a/src/resolvers/Query/TAG.js +++ b/src/resolvers/Query/TAG.js @@ -4,10 +4,18 @@ const tagQuery = { allTags: async (parent, args, info) => { return await prisma.tag.findMany(); }, - suggestTags: async (parent, args, { prisma }, info) => { + + /** + * @param {*} parent + * @param {*} args + * @param {*} info + * @returns + */ + suggestTags: async (parent, args, info) => { const a = await prisma.tag.findMany(); return a.slice(0, 10); }, + tagInfo: async (parent, args, info) => { return await prisma.tag.findUnique({ where: {