diff --git a/package-lock.json b/package-lock.json index 2b34d0847d..a6328e5e21 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4345,9 +4345,9 @@ } }, "bl": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", - "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.3.tgz", + "integrity": "sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==", "dev": true, "requires": { "readable-stream": "^2.3.5", @@ -4485,9 +4485,9 @@ } }, "bson": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.3.tgz", - "integrity": "sha512-TdiJxMVnodVS7r0BdL42y/pqC9cL2iKynVwA0Ho3qbsQYr428veL3l7BQyuqiw+Q5SqqoT0m4srSY/BlZ9AxXg==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bson/-/bson-1.1.5.tgz", + "integrity": "sha512-kDuEzldR21lHciPQAIulLs1LZlCXdLziXI6Mb/TDkwXhb//UORJNPXgcRs2CuO4H0DcMkpfT3/ySsP3unoZjBg==", "dev": true }, "buffer": { @@ -5639,6 +5639,15 @@ "are-we-there-yet": "~1.1.2", "gauge": "~1.2.5" } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } } } }, @@ -6389,9 +6398,9 @@ }, "dependencies": { "type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/type/-/type-2.0.0.tgz", - "integrity": "sha512-KBt58xCHry4Cejnc2ISQAF7QY+ORngsWfxezO68+12hKV6lQY8P/psIkcbjeHWn7MqcgciWJyCCevFMJdIXpow==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/type/-/type-2.1.0.tgz", + "integrity": "sha512-G9absDWvhAWCV2gmF1zKud3OyC61nZDwWvBL2DApaVFogI07CprggiQAOOjvp2NRjYWFzPyu7vwtDrQFq8jeSA==", "dev": true } } @@ -7133,12 +7142,6 @@ "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", "dev": true }, - "graceful-readlink": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", - "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", - "dev": true - }, "graphql": { "version": "15.4.0", "resolved": "https://registry.npmjs.org/graphql/-/graphql-15.4.0.tgz", @@ -7365,9 +7368,9 @@ }, "dependencies": { "readable-stream": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz", - "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==", + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", + "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", "dev": true, "requires": { "inherits": "^2.0.3", @@ -7815,9 +7818,9 @@ } }, "is-mongodb-running": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-mongodb-running/-/is-mongodb-running-1.0.1.tgz", - "integrity": "sha512-gyUmdhGKLHuDv+JGma70b1P1WLBMy8bvt9QLSEojSSi3/5FbUKuOKCNzHmto9ftMjyLtzlUtfCoSGdkPvx6H5w==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-mongodb-running/-/is-mongodb-running-1.0.2.tgz", + "integrity": "sha512-EslN8MErcBPExb+iK4RnG1n28JGjByA2Rm3YPmdHDGCRd7Hc2uvqshyVMAJXxbDSxRMy8vhxims2oRqQUeGJeA==", "dev": true, "requires": { "chalk": "^2.4.1", @@ -9509,9 +9512,8 @@ } }, "mongodb-runner": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/mongodb-runner/-/mongodb-runner-4.8.0.tgz", - "integrity": "sha512-wFTjkqVCkH9MK05t8kSDVP3oSmFq43AYwDBqVWndpggsO+Jr7sBqgf2VlNKlP5xzWF9rX2gqjESyc1Q3QxsXOw==", + "version": "github:mongodb-js/runner#dfb9a520147de6e2537f7c1c21a5e7005d1905f8", + "from": "github:mongodb-js/runner", "dev": true, "requires": { "async": "^3.1.0", @@ -9531,18 +9533,18 @@ }, "dependencies": { "async": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/async/-/async-3.1.0.tgz", - "integrity": "sha512-4vx/aaY6j/j3Lw3fbCHNWP0pPaTCew3F6F3hYyl/tHs/ndmV1q7NW9T5yuJ2XAGwdQrP+6Wu20x06U4APo/iQQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/async/-/async-3.2.0.tgz", + "integrity": "sha512-TR2mEZFVOj2pLStYxLht7TyfuRzaydfpxr3k9RpHIzMgw7A64dzsdqCxH1WJyQdoe8T10nDXd9wnEigmiuHIZw==", "dev": true }, "debug": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", - "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", + "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", "dev": true, "requires": { - "ms": "^2.1.1" + "ms": "2.1.2" } } } @@ -9588,12 +9590,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true - }, - "rimraf": { - "version": "2.2.6", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.6.tgz", - "integrity": "sha1-xZWXVpsU2VatKcrMQr3d9fDqT0w=", - "dev": true } } }, @@ -11056,13 +11052,10 @@ "integrity": "sha1-G0KmJmoh8HQh0bC1S33BZ7AcATs=" }, "rimraf": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", - "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", - "dev": true, - "requires": { - "glob": "^7.1.3" - } + "version": "2.2.6", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.6.tgz", + "integrity": "sha1-xZWXVpsU2VatKcrMQr3d9fDqT0w=", + "dev": true }, "run-async": { "version": "2.3.0", @@ -11117,22 +11110,19 @@ "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" }, "seek-bzip": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.5.tgz", - "integrity": "sha1-z+kXyz0nS8/6x5J1ivUxc+sfq9w=", + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/seek-bzip/-/seek-bzip-1.0.6.tgz", + "integrity": "sha512-e1QtP3YL5tWww8uKaOCQ18UxIT2laNBXHjV/S2WYCiK4udiv8lkG89KRIoCjUagnAmCBurjF4zEVX2ByBbnCjQ==", "dev": true, "requires": { - "commander": "~2.8.1" + "commander": "^2.8.1" }, "dependencies": { "commander": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.8.1.tgz", - "integrity": "sha1-Br42f+v9oMMwqh4qBy09yXYkJdQ=", - "dev": true, - "requires": { - "graceful-readlink": ">= 1.0.0" - } + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true } } }, @@ -12238,9 +12228,9 @@ "dev": true }, "unbzip2-stream": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.0.tgz", - "integrity": "sha512-kVx7CDAsdBSWVf404Mw7oI9i09w5/mTT/Ruk+RWa64PLYKvsAucLLFHvQtnvjeADM4ZizxrvG5SHnF4Te4T2Cg==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/unbzip2-stream/-/unbzip2-stream-1.4.3.tgz", + "integrity": "sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==", "dev": true, "requires": { "buffer": "^5.2.1", @@ -12248,13 +12238,13 @@ }, "dependencies": { "buffer": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.5.0.tgz", - "integrity": "sha512-9FTEDjLjwoAkEwyMGDjYJQN2gfRgOKBKRfiglhvibGbpeeU/pQn1bJxQqm32OD/AIeEuHxU9roxXxg34Byp/Ww==", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", "dev": true, "requires": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" } } } diff --git a/package.json b/package.json index 7cb57d2f7a..3450f3cf3d 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "jsdoc": "3.6.3", "jsdoc-babel": "0.5.0", "lint-staged": "10.2.3", - "mongodb-runner": "4.8.0", + "mongodb-runner": "mongodb-js/runner", "node-fetch": "2.6.1", "nyc": "15.1.0", "prettier": "2.0.5" @@ -113,7 +113,7 @@ "node": ">= 8" }, "bin": { - "parse-server": "./bin/parse-server" + "parse-server": "bin/parse-server" }, "optionalDependencies": { "@node-rs/bcrypt": "0.4.1" diff --git a/spec/ParseGraphQLServer.spec.js b/spec/ParseGraphQLServer.spec.js index 5bba32f2a1..dad9bda3df 100644 --- a/spec/ParseGraphQLServer.spec.js +++ b/spec/ParseGraphQLServer.spec.js @@ -964,7 +964,7 @@ describe('ParseGraphQLServer', () => { .map(field => field.name) .sort(); - expect(payloadFields).toEqual(['clientMutationId', 'viewer']); + expect(payloadFields).toEqual(['clientMutationId', 'ok']); }); it('should have clientMutationId in createClass mutation input', async () => { @@ -6943,9 +6943,7 @@ describe('ParseGraphQLServer', () => { mutation LogOutUser($input: LogOutInput!) { logOut(input: $input) { clientMutationId - viewer { - sessionToken - } + ok } } `, @@ -6961,7 +6959,7 @@ describe('ParseGraphQLServer', () => { }, }); expect(logOut.data.logOut.clientMutationId).toEqual(clientMutationId); - expect(logOut.data.logOut.viewer.sessionToken).toEqual(sessionToken); + expect(logOut.data.logOut.ok).toEqual(true); try { await apolloClient.query({ diff --git a/src/GraphQL/loaders/usersMutations.js b/src/GraphQL/loaders/usersMutations.js index 34f58205fc..9c57c85125 100644 --- a/src/GraphQL/loaders/usersMutations.js +++ b/src/GraphQL/loaders/usersMutations.js @@ -1,9 +1,4 @@ -import { - GraphQLNonNull, - GraphQLString, - GraphQLBoolean, - GraphQLInputObjectType, -} from 'graphql'; +import { GraphQLNonNull, GraphQLString, GraphQLBoolean, GraphQLInputObjectType } from 'graphql'; import { mutationWithClientMutationId } from 'graphql-relay'; import UsersRouter from '../../Routers/UsersRouter'; import * as objectsMutations from '../helpers/objectsMutations'; @@ -20,20 +15,16 @@ const load = parseGraphQLSchema => { const signUpMutation = mutationWithClientMutationId({ name: 'SignUp', - description: - 'The signUp mutation can be used to create and sign up a new user.', + description: 'The signUp mutation can be used to create and sign up a new user.', inputFields: { fields: { - descriptions: - 'These are the fields of the new user to be created and signed up.', - type: - parseGraphQLSchema.parseClassTypes['_User'].classGraphQLCreateType, + descriptions: 'These are the fields of the new user to be created and signed up.', + type: parseGraphQLSchema.parseClassTypes['_User'].classGraphQLCreateType, }, }, outputFields: { viewer: { - description: - 'This is the new user that was created, signed up and returned as a viewer.', + description: 'This is the new user that was created, signed up and returned as a viewer.', type: new GraphQLNonNull(parseGraphQLSchema.viewerType), }, }, @@ -59,12 +50,7 @@ const load = parseGraphQLSchema => { context.info.sessionToken = sessionToken; return { - viewer: await getUserFromSessionToken( - context, - mutationInfo, - 'viewer.user.', - objectId - ), + viewer: await getUserFromSessionToken(context, mutationInfo, 'viewer.user.', objectId), }; } catch (e) { parseGraphQLSchema.handleError(e); @@ -72,11 +58,7 @@ const load = parseGraphQLSchema => { }, }); - parseGraphQLSchema.addGraphQLType( - signUpMutation.args.input.type.ofType, - true, - true - ); + parseGraphQLSchema.addGraphQLType(signUpMutation.args.input.type.ofType, true, true); parseGraphQLSchema.addGraphQLType(signUpMutation.type, true, true); parseGraphQLSchema.addGraphQLMutation('signUp', signUpMutation, true, true); const logInWithMutation = mutationWithClientMutationId({ @@ -89,35 +71,30 @@ const load = parseGraphQLSchema => { type: new GraphQLNonNull(OBJECT), }, fields: { - descriptions: - 'These are the fields of the user to be created/updated and logged in.', + descriptions: 'These are the fields of the user to be created/updated and logged in.', type: new GraphQLInputObjectType({ name: 'UserLoginWithInput', fields: () => { const classGraphQLCreateFields = parseGraphQLSchema.parseClassTypes[ '_User' ].classGraphQLCreateType.getFields(); - return Object.keys(classGraphQLCreateFields).reduce( - (fields, fieldName) => { - if ( - fieldName !== 'password' && - fieldName !== 'username' && - fieldName !== 'authData' - ) { - fields[fieldName] = classGraphQLCreateFields[fieldName]; - } - return fields; - }, - {} - ); + return Object.keys(classGraphQLCreateFields).reduce((fields, fieldName) => { + if ( + fieldName !== 'password' && + fieldName !== 'username' && + fieldName !== 'authData' + ) { + fields[fieldName] = classGraphQLCreateFields[fieldName]; + } + return fields; + }, {}); }, }), }, }, outputFields: { viewer: { - description: - 'This is the new user that was created, signed up and returned as a viewer.', + description: 'This is the new user that was created, signed up and returned as a viewer.', type: new GraphQLNonNull(parseGraphQLSchema.viewerType), }, }, @@ -143,12 +120,7 @@ const load = parseGraphQLSchema => { context.info.sessionToken = sessionToken; return { - viewer: await getUserFromSessionToken( - context, - mutationInfo, - 'viewer.user.', - objectId - ), + viewer: await getUserFromSessionToken(context, mutationInfo, 'viewer.user.', objectId), }; } catch (e) { parseGraphQLSchema.handleError(e); @@ -156,18 +128,9 @@ const load = parseGraphQLSchema => { }, }); - parseGraphQLSchema.addGraphQLType( - logInWithMutation.args.input.type.ofType, - true, - true - ); + parseGraphQLSchema.addGraphQLType(logInWithMutation.args.input.type.ofType, true, true); parseGraphQLSchema.addGraphQLType(logInWithMutation.type, true, true); - parseGraphQLSchema.addGraphQLMutation( - 'logInWith', - logInWithMutation, - true, - true - ); + parseGraphQLSchema.addGraphQLMutation('logInWith', logInWithMutation, true, true); const logInMutation = mutationWithClientMutationId({ name: 'LogIn', @@ -184,8 +147,7 @@ const load = parseGraphQLSchema => { }, outputFields: { viewer: { - description: - 'This is the existing user that was logged in and returned as a viewer.', + description: 'This is the existing user that was logged in and returned as a viewer.', type: new GraphQLNonNull(parseGraphQLSchema.viewerType), }, }, @@ -210,12 +172,7 @@ const load = parseGraphQLSchema => { context.info.sessionToken = sessionToken; return { - viewer: await getUserFromSessionToken( - context, - mutationInfo, - 'viewer.user.', - objectId - ), + viewer: await getUserFromSessionToken(context, mutationInfo, 'viewer.user.', objectId), }; } catch (e) { parseGraphQLSchema.handleError(e); @@ -223,11 +180,7 @@ const load = parseGraphQLSchema => { }, }); - parseGraphQLSchema.addGraphQLType( - logInMutation.args.input.type.ofType, - true, - true - ); + parseGraphQLSchema.addGraphQLType(logInMutation.args.input.type.ofType, true, true); parseGraphQLSchema.addGraphQLType(logInMutation.type, true, true); parseGraphQLSchema.addGraphQLMutation('logIn', logInMutation, true, true); @@ -235,41 +188,29 @@ const load = parseGraphQLSchema => { name: 'LogOut', description: 'The logOut mutation can be used to log out an existing user.', outputFields: { - viewer: { - description: - 'This is the existing user that was logged out and returned as a viewer.', - type: new GraphQLNonNull(parseGraphQLSchema.viewerType), + ok: { + description: "It's always true.", + type: new GraphQLNonNull(GraphQLBoolean), }, }, - mutateAndGetPayload: async (_args, context, mutationInfo) => { + mutateAndGetPayload: async (_args, context) => { try { const { config, auth, info } = context; - const viewer = await getUserFromSessionToken( - context, - mutationInfo, - 'viewer.user.', - auth.user.id - ); - await usersRouter.handleLogOut({ config, auth, info, }); - return { viewer }; + return { ok: true }; } catch (e) { parseGraphQLSchema.handleError(e); } }, }); - parseGraphQLSchema.addGraphQLType( - logOutMutation.args.input.type.ofType, - true, - true - ); + parseGraphQLSchema.addGraphQLType(logOutMutation.args.input.type.ofType, true, true); parseGraphQLSchema.addGraphQLType(logOutMutation.type, true, true); parseGraphQLSchema.addGraphQLMutation('logOut', logOutMutation, true, true); @@ -305,18 +246,9 @@ const load = parseGraphQLSchema => { }, }); - parseGraphQLSchema.addGraphQLType( - resetPasswordMutation.args.input.type.ofType, - true, - true - ); + parseGraphQLSchema.addGraphQLType(resetPasswordMutation.args.input.type.ofType, true, true); parseGraphQLSchema.addGraphQLType(resetPasswordMutation.type, true, true); - parseGraphQLSchema.addGraphQLMutation( - 'resetPassword', - resetPasswordMutation, - true, - true - ); + parseGraphQLSchema.addGraphQLMutation('resetPassword', resetPasswordMutation, true, true); const sendVerificationEmailMutation = mutationWithClientMutationId({ name: 'SendVerificationEmail', @@ -324,8 +256,7 @@ const load = parseGraphQLSchema => { 'The sendVerificationEmail mutation can be used to send the verification email again.', inputFields: { email: { - descriptions: - 'Email of the user that should receive the verification email', + descriptions: 'Email of the user that should receive the verification email', type: new GraphQLNonNull(GraphQLString), }, }, @@ -360,11 +291,7 @@ const load = parseGraphQLSchema => { true, true ); - parseGraphQLSchema.addGraphQLType( - sendVerificationEmailMutation.type, - true, - true - ); + parseGraphQLSchema.addGraphQLType(sendVerificationEmailMutation.type, true, true); parseGraphQLSchema.addGraphQLMutation( 'sendVerificationEmail', sendVerificationEmailMutation,