Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Before you start make sure you have installed:
- Optionally [Docker](https://www.docker.com/)

### Locally
```
```bash
$ npm install -g parse-server mongodb-runner
$ mongodb-runner start
$ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongodb://localhost/test
Expand All @@ -94,7 +94,7 @@ $ parse-server --appId APPLICATION_ID --masterKey MASTER_KEY --databaseURI mongo


### Inside a Docker container
```
```bash
$ git clone https://github.com/parse-community/parse-server
$ cd parse-server
$ docker build --tag parse-server .
Expand All @@ -113,7 +113,7 @@ That's it! You are now running a standalone version of Parse Server on your mach
Now that you're running Parse Server, it is time to save your first object. We'll use the [REST API](http://docs.parseplatform.org/rest/guide), but you can easily do the same using any of the [Parse SDKs](http://parseplatform.org/#sdks). Run the following:

```bash
curl -X POST \
$ curl -X POST \
-H "X-Parse-Application-Id: APPLICATION_ID" \
-H "Content-Type: application/json" \
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
Expand Down Expand Up @@ -150,7 +150,7 @@ $ curl -X GET \

Keeping tracks of individual object ids is not ideal, however. In most cases you will want to run a query over the collection, like so:

```
```bash
$ curl -X GET \
-H "X-Parse-Application-Id: APPLICATION_ID" \
http://localhost:1337/parse/classes/GameScore
Expand Down
1,437 changes: 696 additions & 741 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@parse/push-adapter": "3.2.0",
"@parse/s3-files-adapter": "1.4.0",
"@parse/simple-mailgun-adapter": "1.1.0",
"apollo-server-express": "2.9.14",
"apollo-server-express": "2.9.15",
"bcryptjs": "2.4.3",
"body-parser": "1.19.0",
"commander": "4.0.1",
Expand All @@ -43,26 +43,26 @@
"lodash": "4.17.15",
"lru-cache": "5.1.1",
"mime": "2.4.4",
"mongodb": "3.4.0",
"mongodb": "3.4.1",
"node-rsa": "1.0.7",
"parse": "2.10.0",
"pg-promise": "10.3.1",
"parse": "2.11.0",
"pg-promise": "10.3.2",
"pluralize": "^8.0.0",
"redis": "2.8.0",
"semver": "7.1.1",
"subscriptions-transport-ws": "0.9.16",
"tv4": "1.3.0",
"uuid": "3.3.3",
"winston": "3.2.1",
"winston-daily-rotate-file": "3.10.0",
"winston-daily-rotate-file": "4.4.0",
"ws": "7.2.1"
},
"devDependencies": {
"@babel/cli": "7.7.5",
"@babel/core": "7.7.5",
"@babel/plugin-proposal-object-rest-spread": "7.7.4",
"@babel/cli": "7.7.7",
"@babel/core": "7.7.7",
"@babel/plugin-proposal-object-rest-spread": "7.7.7",
"@babel/plugin-transform-flow-strip-types": "7.7.4",
"@babel/preset-env": "7.7.6",
"@babel/preset-env": "7.7.7",
"@parse/minami": "1.0.0",
"apollo-cache-inmemory": "1.6.5",
"apollo-client": "2.6.6",
Expand All @@ -75,9 +75,9 @@
"bcrypt-nodejs": "0.0.3",
"cross-env": "6.0.3",
"deep-diff": "1.0.2",
"eslint": "6.7.2",
"eslint": "6.8.0",
"eslint-plugin-flowtype": "4.5.0",
"flow-bin": "0.114.0",
"flow-bin": "0.115.0",
"form-data": "3.0.0",
"gaze": "1.1.3",
"graphql-tag": "^2.10.1",
Expand All @@ -88,7 +88,7 @@
"lint-staged": "9.5.0",
"mongodb-runner": "4.7.5",
"node-fetch": "2.6.0",
"nyc": "14.1.1",
"nyc": "15.0.0",
"prettier": "1.19.0"
},
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions resources/buildConfigDefinitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ function inject(t, list) {
if (type === 'NumberOrBoolean') {
type = 'Number|Boolean';
}
if (type === 'NumberOrString') {
type = 'Number|String';
}
if (type === 'Adapter') {
const adapterType = elt.typeAnnotation.typeParameters.params[0].id.name;
type = `Adapter<${adapterType}>`;
Expand Down
179 changes: 179 additions & 0 deletions spec/ParseGraphQLServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ describe('ParseGraphQLServer', () => {
user1 = new Parse.User();
user1.setUsername('user1');
user1.setPassword('user1');
user1.setEmail('[email protected]');
await user1.signUp();

user2 = new Parse.User();
Expand Down Expand Up @@ -371,6 +372,7 @@ describe('ParseGraphQLServer', () => {

object1 = new Parse.Object('GraphQLClass');
object1.set('someField', 'someValue1');
object1.set('someOtherField', 'A');
const object1ACL = new Parse.ACL();
object1ACL.setPublicReadAccess(false);
object1ACL.setPublicWriteAccess(false);
Expand All @@ -385,6 +387,7 @@ describe('ParseGraphQLServer', () => {

object2 = new Parse.Object('GraphQLClass');
object2.set('someField', 'someValue2');
object2.set('someOtherField', 'A');
const object2ACL = new Parse.ACL();
object2ACL.setPublicReadAccess(false);
object2ACL.setPublicWriteAccess(false);
Expand All @@ -399,6 +402,7 @@ describe('ParseGraphQLServer', () => {

object3 = new Parse.Object('GraphQLClass');
object3.set('someField', 'someValue3');
object3.set('someOtherField', 'B');
object3.set('pointerToUser', user5);
await object3.save(undefined, { useMasterKey: true });

Expand Down Expand Up @@ -5936,6 +5940,98 @@ describe('ParseGraphQLServer', () => {
}
});
});

it('should order by multiple fields', async () => {
await prepareData();

await resetGraphQLCache();

let result;
try {
result = await apolloClient.query({
query: gql`
query OrderByMultipleFields($order: [GraphQLClassOrder!]) {
graphQLClasses(order: $order) {
edges {
node {
objectId
}
}
}
}
`,
variables: {
order: ['someOtherField_DESC', 'someField_ASC'],
},
context: {
headers: {
'X-Parse-Master-Key': 'test',
},
},
});
} catch (e) {
handleError(e);
}

expect(
result.data.graphQLClasses.edges.map(edge => edge.node.objectId)
).toEqual([object3.id, object1.id, object2.id]);
});

it_only_db('mongo')(
'should order by multiple fields on a relation field',
async () => {
await prepareData();

const parentObject = new Parse.Object('ParentClass');
const relation = parentObject.relation('graphQLClasses');
relation.add(object1);
relation.add(object2);
relation.add(object3);
await parentObject.save();

await resetGraphQLCache();

let result;
try {
result = await apolloClient.query({
query: gql`
query OrderByMultipleFieldsOnRelation(
$id: ID!
$order: [GraphQLClassOrder!]
) {
parentClass(id: $id) {
graphQLClasses(order: $order) {
edges {
node {
objectId
}
}
}
}
}
`,
variables: {
id: parentObject.id,
order: ['someOtherField_DESC', 'someField_ASC'],
},
context: {
headers: {
'X-Parse-Master-Key': 'test',
},
},
});
} catch (e) {
handleError(e);
}

expect(
result.data.parentClass.graphQLClasses.edges.map(
edge => edge.node.objectId
)
).toEqual([object3.id, object1.id, object2.id]);
}
);
});
});

Expand Down Expand Up @@ -7149,6 +7245,89 @@ describe('ParseGraphQLServer', () => {
});
}
});

it('should send reset password', async () => {
const clientMutationId = uuidv4();
const emailAdapter = {
sendVerificationEmail: () => {},
sendPasswordResetEmail: () => Promise.resolve(),
sendMail: () => {},
};
parseServer = await global.reconfigureServer({
appName: 'test',
emailAdapter: emailAdapter,
publicServerURL: 'http://test.test',
});
const user = new Parse.User();
user.setUsername('user1');
user.setPassword('user1');
user.setEmail('[email protected]');
await user.signUp();
await Parse.User.logOut();
const result = await apolloClient.mutate({
mutation: gql`
mutation ResetPassword($input: ResetPasswordInput!) {
resetPassword(input: $input) {
clientMutationId
ok
}
}
`,
variables: {
input: {
clientMutationId,
email: '[email protected]',
},
},
});

expect(result.data.resetPassword.clientMutationId).toEqual(
clientMutationId
);
expect(result.data.resetPassword.ok).toBeTruthy();
});
it('should send verification email again', async () => {
const clientMutationId = uuidv4();
const emailAdapter = {
sendVerificationEmail: () => {},
sendPasswordResetEmail: () => Promise.resolve(),
sendMail: () => {},
};
parseServer = await global.reconfigureServer({
appName: 'test',
emailAdapter: emailAdapter,
publicServerURL: 'http://test.test',
});
const user = new Parse.User();
user.setUsername('user1');
user.setPassword('user1');
user.setEmail('[email protected]');
await user.signUp();
await Parse.User.logOut();
const result = await apolloClient.mutate({
mutation: gql`
mutation SendVerificationEmail(
$input: SendVerificationEmailInput!
) {
sendVerificationEmail(input: $input) {
clientMutationId
ok
}
}
`,
variables: {
input: {
clientMutationId,
email: '[email protected]',
},
},
});

expect(result.data.sendVerificationEmail.clientMutationId).toEqual(
clientMutationId
);
expect(result.data.sendVerificationEmail.ok).toBeTruthy();
});
});

describe('Session Token', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/Adapters/Logger/WinstonLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function configureLogger({
logLevel = winston.level,
verbose = defaults.verbose,
silent = defaults.silent,
maxLogFiles,
} = {}) {
if (verbose) {
logLevel = 'verbose';
Expand All @@ -100,6 +101,7 @@ export function configureLogger({
options.dirname = logsFolder;
options.level = logLevel;
options.silent = silent;
options.maxFiles = maxLogFiles;

if (jsonLogs) {
options.json = true;
Expand Down
10 changes: 9 additions & 1 deletion src/Controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,18 @@ export function getLoggerController(
logsFolder,
verbose,
logLevel,
maxLogFiles,
silent,
loggerAdapter,
} = options;
const loggerOptions = { jsonLogs, logsFolder, verbose, logLevel, silent };
const loggerOptions = {
jsonLogs,
logsFolder,
verbose,
logLevel,
silent,
maxLogFiles,
};
const loggerControllerAdapter = loadAdapter(
loggerAdapter,
WinstonLoggerAdapter,
Expand Down
2 changes: 2 additions & 0 deletions src/GraphQL/helpers/objectsQueries.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ const findObjects = async (
) {
if (limit || limit === 0) {
options.limit = limit;
} else {
options.limit = 100;
}
if (options.limit !== 0) {
if (order) {
Expand Down
Loading