Skip to content

Commit f1e3b6a

Browse files
authored
Merge branch 'alpha' into graphql-where-argument-with-false-value-on-object-field
2 parents a75c8cf + 0d16a64 commit f1e3b6a

7 files changed

+184
-56
lines changed

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Table of Contents <!-- omit in toc -->
44
- [Contributing](#contributing)
5+
- [Templates](#templates)
56
- [Why Contributing?](#why-contributing)
67
- [Environment Setup](#environment-setup)
78
- [Recommended Tools](#recommended-tools)
@@ -49,6 +50,22 @@ When you are ready to code, you can find more information about opening a pull r
4950

5051
Whether this is your first contribution or you are already an experienced contributor, the Parse Community has your back – don't hesitate to ask for help!
5152

53+
### Issue vs. Pull Request
54+
55+
An issue is required to be linked in every pull request. We understand that no-one likes to create an issue for something that appears to be a simple pull request, but here is why this is beneficial for everyone:
56+
57+
- An issue get more visibility than a pull request as issues can be pinned, receive bounties and it is primarily the issue list that people browse through rather than the more technical pull request list. Visibility is a key aspect so others can weigh in on issues and contribute their opinion.
58+
- The discussion in the issue is different from the discussion in the pull request. The issue discussion is focused on the issue and how to address it, whereas the discussion in the pull request is focused on a specific implemention. An issue may even have multiple pull requests because either the issue requires multiple implementations or multiple pull requests are opened to compare and test different approaches to later decide for one.
59+
- High-level conceptual discussions about the issue should be still available, even if a pull request is closed because its appraoch was discarded. If these discussions are in the pull request instead, they can easily become fragmented over multiple pull requests and issues, which can make it very hard to make sense of all aspects of an issue.
60+
61+
### Templates
62+
63+
You are required to use and completely fill out the templates for new issues and pull requests. We understand that no-one enjoys filling out forms, but here is why this is beneficial for everyone:
64+
65+
- It may take you 30 seconds longer, but will save even more time for everyone else trying to understand your issue.
66+
- It helps to fix issues and merge pull requests faster as reviewers spend less time trying to understand your issue.
67+
- It makes investigations easier when others try to understand your issue and code changes made even years later.
68+
5269
## Why Contributing?
5370

5471
Buy cheap, buy twice. What? No, this is not the Economics 101 class, but the same is true for contributing.

package-lock.json

Lines changed: 38 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"license": "BSD-3-Clause",
2121
"dependencies": {
2222
"@graphql-yoga/node": "2.6.0",
23-
"@graphql-tools/utils": "8.6.12",
23+
"@graphql-tools/utils": "8.6.13",
2424
"@graphql-tools/merge": "8.2.13",
25-
"@graphql-tools/schema": "8.3.13",
25+
"@graphql-tools/schema": "8.3.14",
2626
"@parse/fs-files-adapter": "1.2.2",
2727
"@parse/push-adapter": "4.1.2",
2828
"bcryptjs": "2.4.3",
@@ -38,7 +38,7 @@
3838
"graphql-relay": "0.10.0",
3939
"intersect": "1.0.1",
4040
"jsonwebtoken": "8.5.1",
41-
"jwks-rsa": "2.1.3",
41+
"jwks-rsa": "2.1.4",
4242
"ldapjs": "2.3.2",
4343
"lodash": "4.17.21",
4444
"lru-cache": "7.10.1",
@@ -56,7 +56,7 @@
5656
"uuid": "8.3.2",
5757
"winston": "3.7.2",
5858
"winston-daily-rotate-file": "4.7.1",
59-
"ws": "8.7.0"
59+
"ws": "8.8.0"
6060
},
6161
"devDependencies": {
6262
"graphql-tag": "2.12.6",

spec/ParseLiveQuery.spec.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,52 @@ describe('ParseLiveQuery', function () {
11101110
}
11111111
});
11121112

1113+
it('should strip out protected fields', async () => {
1114+
await reconfigureServer({
1115+
liveQuery: { classNames: ['Test'] },
1116+
startLiveQueryServer: true,
1117+
});
1118+
const obj1 = new Parse.Object('Test');
1119+
obj1.set('foo', 'foo');
1120+
obj1.set('bar', 'bar');
1121+
obj1.set('qux', 'qux');
1122+
await obj1.save();
1123+
const config = Config.get(Parse.applicationId);
1124+
const schemaController = await config.database.loadSchema();
1125+
await schemaController.updateClass(
1126+
'Test',
1127+
{},
1128+
{
1129+
get: { '*': true },
1130+
find: { '*': true },
1131+
update: { '*': true },
1132+
protectedFields: {
1133+
'*': ['foo'],
1134+
},
1135+
}
1136+
);
1137+
const object = await obj1.fetch();
1138+
expect(object.get('foo')).toBe(undefined);
1139+
expect(object.get('bar')).toBeDefined();
1140+
expect(object.get('qux')).toBeDefined();
1141+
1142+
const subscription = await new Parse.Query('Test').subscribe();
1143+
await Promise.all([
1144+
new Promise(resolve => {
1145+
subscription.on('update', (obj, original) => {
1146+
expect(obj.get('foo')).toBe(undefined);
1147+
expect(obj.get('bar')).toBeDefined();
1148+
expect(obj.get('qux')).toBeDefined();
1149+
expect(original.get('foo')).toBe(undefined);
1150+
expect(original.get('bar')).toBeDefined();
1151+
expect(original.get('qux')).toBeDefined();
1152+
resolve();
1153+
});
1154+
}),
1155+
obj1.save({ foo: 'abc' }),
1156+
]);
1157+
});
1158+
11131159
afterEach(async function (done) {
11141160
const client = await Parse.CoreManager.getLiveQueryController().getDefaultLiveQueryClient();
11151161
client.close();

src/Controllers/DatabaseController.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const filterSensitiveData = (
127127
aclGroup: any[],
128128
auth: any,
129129
operation: any,
130-
schema: SchemaController.SchemaController,
130+
schema: SchemaController.SchemaController | any,
131131
className: string,
132132
protectedFields: null | Array<any>,
133133
object: any
@@ -136,7 +136,8 @@ const filterSensitiveData = (
136136
if (auth && auth.user) userId = auth.user.id;
137137

138138
// replace protectedFields when using pointer-permissions
139-
const perms = schema.getClassLevelPermissions(className);
139+
const perms =
140+
schema && schema.getClassLevelPermissions ? schema.getClassLevelPermissions(className) : {};
140141
if (perms) {
141142
const isReadOperation = ['get', 'find'].indexOf(operation) > -1;
142143

@@ -1533,14 +1534,17 @@ class DatabaseController {
15331534
}
15341535

15351536
addProtectedFields(
1536-
schema: SchemaController.SchemaController,
1537+
schema: SchemaController.SchemaController | any,
15371538
className: string,
15381539
query: any = {},
15391540
aclGroup: any[] = [],
15401541
auth: any = {},
15411542
queryOptions: FullQueryOptions = {}
15421543
): null | string[] {
1543-
const perms = schema.getClassLevelPermissions(className);
1544+
const perms =
1545+
schema && schema.getClassLevelPermissions
1546+
? schema.getClassLevelPermissions(className)
1547+
: schema;
15441548
if (!perms) return null;
15451549

15461550
const protectedFields = perms.protectedFields;
@@ -1806,8 +1810,10 @@ class DatabaseController {
18061810
}
18071811

18081812
static _validateQuery: any => void;
1813+
static filterSensitiveData: (boolean, any[], any, any, any, string, any[], any) => void;
18091814
}
18101815

18111816
module.exports = DatabaseController;
18121817
// Expose validateQuery for tests
18131818
module.exports._validateQuery = validateQuery;
1819+
module.exports.filterSensitiveData = filterSensitiveData;

src/LiveQuery/ParseCloudCodePublisher.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class ParseCloudCodePublisher {
4040
if (request.original) {
4141
message.originalParseObject = request.original._toFullJSON();
4242
}
43+
if (request.classLevelPermissions) {
44+
message.classLevelPermissions = request.classLevelPermissions;
45+
}
4346
this.parsePublisher.publish(type, JSON.stringify(message));
4447
}
4548
}

0 commit comments

Comments
 (0)