Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Switch from Yoga v2 to Apollo V4 merge #8893

Closed
Show file tree
Hide file tree
Changes from 10 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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
- name: Node 18
MONGODB_VERSION: 4.4.13
MONGODB_TOPOLOGY: standalone
NODE_VERSION: 18.12.1
NODE_VERSION: 18.18.2
fail-fast: false
name: ${{ matrix.name }}
timeout-minutes: 15
Expand Down
1,659 changes: 1,145 additions & 514 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
],
"license": "Apache-2.0",
"dependencies": {
"@apollo/server": "4.9.2",
"@babel/eslint-parser": "7.21.8",
"@graphql-tools/merge": "8.4.1",
"@graphql-tools/schema": "9.0.4",
"@graphql-tools/utils": "8.12.0",
"@graphql-yoga/node": "2.6.0",
"@parse/fs-files-adapter": "1.2.2",
"@parse/push-adapter": "5.0.2",
"bcryptjs": "2.4.3",
Expand All @@ -38,6 +38,7 @@
"graphql-list-fields": "2.0.2",
"graphql-relay": "0.10.0",
"graphql-tag": "2.12.6",
"graphql-upload": "15.0.2",
"intersect": "1.0.1",
"jsonwebtoken": "9.0.0",
"jwks-rsa": "2.1.5",
Expand Down
28 changes: 20 additions & 8 deletions spec/EmailVerificationToken.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ describe('Email Verification Token Expiration: ', () => {
await user.signUp();

const verifyUserEmails = {
method: async (params) => {
method: async params => {
expect(params.object).toBeInstanceOf(Parse.User);
expect(params.ip).toBeDefined();
expect(params.master).toBeDefined();
Expand Down Expand Up @@ -942,9 +942,14 @@ describe('Email Verification Token Expiration: ', () => {
await user.signUp();

const config = Config.get('test');
const [userBeforeRequest] = await config.database.find('_User', {
username: 'resends_verification_token',
}, {}, Auth.maintenance(config));
const [userBeforeRequest] = await config.database.find(
'_User',
{
username: 'resends_verification_token',
},
{},
Auth.maintenance(config)
);
// store this user before we make our email request
expect(sendVerificationEmailCallCount).toBe(1);
await new Promise(resolve => {
Expand All @@ -969,16 +974,23 @@ describe('Email Verification Token Expiration: ', () => {
expect(sendVerificationEmailCallCount).toBe(2);
expect(sendEmailOptions).toBeDefined();

const [userAfterRequest] = await config.database.find('_User', {
username: 'resends_verification_token',
}, {}, Auth.maintenance(config));
const [userAfterRequest] = await config.database.find(
'_User',
{
username: 'resends_verification_token',
},
{},
Auth.maintenance(config)
);

// Verify that token & expiration haven't been changed for this new request
expect(typeof userAfterRequest).toBe('object');
expect(userBeforeRequest._email_verify_token).toBeDefined();
expect(userBeforeRequest._email_verify_token).toEqual(userAfterRequest._email_verify_token);
expect(userBeforeRequest._email_verify_token_expires_at).toBeDefined();
expect(userBeforeRequest._email_verify_token_expires_at).toEqual(userAfterRequest._email_verify_token_expires_at);
expect(userBeforeRequest._email_verify_token_expires_at).toEqual(
userAfterRequest._email_verify_token_expires_at
);
done();
});

Expand Down
81 changes: 69 additions & 12 deletions spec/ParseGraphQLServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ describe('ParseGraphQLServer', () => {
let parseGraphQLServer;

beforeEach(async () => {
parseServer = await global.reconfigureServer({});
parseServer = await global.reconfigureServer({
maxUploadSize: '1kb',
});
parseGraphQLServer = new ParseGraphQLServer(parseServer, {
graphQLPath: '/graphql',
playgroundPath: '/playground',
Expand Down Expand Up @@ -122,15 +124,16 @@ describe('ParseGraphQLServer', () => {
info: new Object(),
config: new Object(),
auth: new Object(),
get: () => {},
};
const res = {
set: () => {},
};

it("should return schema and context with req's info, config and auth", async () => {
const options = await parseGraphQLServer._getGraphQLOptions();
expect(options.multipart).toEqual({
fileSize: 20971520,
});
expect(options.schema).toEqual(parseGraphQLServer.parseGraphQLSchema.graphQLSchema);
const contextResponse = options.context({ req });
const contextResponse = await options.context({ req, res });
expect(contextResponse.info).toEqual(req.info);
expect(contextResponse.config).toEqual(req.config);
expect(contextResponse.auth).toEqual(req.auth);
Expand Down Expand Up @@ -6832,7 +6835,7 @@ describe('ParseGraphQLServer', () => {

describe('Files Mutations', () => {
describe('Create', () => {
it_only_node_version('<17')('should return File object', async () => {
it('should return File object', async () => {
const clientMutationId = uuidv4();

parseServer = await global.reconfigureServer({
Expand Down Expand Up @@ -9298,7 +9301,7 @@ describe('ParseGraphQLServer', () => {
expect(result6[0].node.name).toEqual('imACountry3');
});

it_only_node_version('<17')('should support files', async () => {
it('should support files', async () => {
try {
parseServer = await global.reconfigureServer({
publicServerURL: 'http://localhost:13377/parse',
Expand Down Expand Up @@ -9340,7 +9343,6 @@ describe('ParseGraphQLServer', () => {
expect(res.status).toEqual(200);

const result = JSON.parse(await res.text());

expect(result.data.createFile.fileInfo.name).toEqual(
jasmine.stringMatching(/_myFileName.txt$/)
);
Expand Down Expand Up @@ -9546,9 +9548,61 @@ describe('ParseGraphQLServer', () => {
}
});

it_only_node_version('<17')('should not upload if file is too large', async () => {
parseGraphQLServer.parseServer.config.maxUploadSize = '1kb';
it('should support files and add extension from mimetype', async () => {
try {
parseServer = await global.reconfigureServer({
publicServerURL: 'http://localhost:13377/parse',
});

const body = new FormData();
body.append(
'operations',
JSON.stringify({
query: `
mutation CreateFile($input: CreateFileInput!) {
createFile(input: $input) {
fileInfo {
name
url
}
}
}
`,
variables: {
input: {
upload: null,
},
},
})
);
body.append('map', JSON.stringify({ 1: ['variables.input.upload'] }));
body.append('1', 'My File Content', {
// No extension, the system should add it from mimetype
filename: 'myFileName',
contentType: 'text/plain',
});

const res = await fetch('http://localhost:13377/graphql', {
method: 'POST',
headers,
body,
});

expect(res.status).toEqual(200);

const result = JSON.parse(await res.text());
expect(result.data.createFile.fileInfo.name).toEqual(
jasmine.stringMatching(/_myFileName.txt$/)
);
expect(result.data.createFile.fileInfo.url).toEqual(
jasmine.stringMatching(/_myFileName.txt$/)
);
} catch (e) {
handleError(e);
}
});

it('should not upload if file is too large', async () => {
const body = new FormData();
body.append(
'operations',
Expand All @@ -9573,6 +9627,7 @@ describe('ParseGraphQLServer', () => {
body.append('map', JSON.stringify({ 1: ['variables.input.upload'] }));
body.append(
'1',
// In this test file parse server is setup with 1kb limit
Buffer.alloc(parseGraphQLServer._transformMaxUploadSizeToBytes('2kb'), 1),
{
filename: 'myFileName.txt',
Expand All @@ -9587,8 +9642,10 @@ describe('ParseGraphQLServer', () => {
});

const result = JSON.parse(await res.text());
expect(res.status).toEqual(500);
expect(result.errors[0].message).toEqual('File size limit exceeded: 1024 bytes');
expect(res.status).toEqual(200);
expect(result.errors[0].message).toEqual(
'File truncated as it exceeds the 1024 byte size limit.'
);
});

it('should support object values', async () => {
Expand Down
22 changes: 18 additions & 4 deletions spec/UserController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,19 @@ describe('UserController', () => {
await user.signUp();

const config = Config.get('test');
const rawUser = await config.database.find('_User', { username }, {}, Auth.maintenance(config));
const rawUser = await config.database.find(
'_User',
{ username },
{},
Auth.maintenance(config)
);
const rawUsername = rawUser[0].username;
const rawToken = rawUser[0]._email_verify_token;
expect(rawToken).toBeDefined();
expect(rawUsername).toBe(username);
expect(emailOptions.link).toEqual(`http://www.example.com/apps/test/verify_email?token=${rawToken}&username=${username}`);
expect(emailOptions.link).toEqual(
`http://www.example.com/apps/test/verify_email?token=${rawToken}&username=${username}`
);
});
});

Expand Down Expand Up @@ -65,12 +72,19 @@ describe('UserController', () => {
await user.signUp();

const config = Config.get('test');
const rawUser = await config.database.find('_User', { username }, {}, Auth.maintenance(config));
const rawUser = await config.database.find(
'_User',
{ username },
{},
Auth.maintenance(config)
);
const rawUsername = rawUser[0].username;
const rawToken = rawUser[0]._email_verify_token;
expect(rawToken).toBeDefined();
expect(rawUsername).toBe(username);
expect(emailOptions.link).toEqual(`http://someother.example.com/handle-parse-iframe?link=%2Fapps%2Ftest%2Fverify_email&token=${rawToken}&username=${username}`);
expect(emailOptions.link).toEqual(
`http://someother.example.com/handle-parse-iframe?link=%2Fapps%2Ftest%2Fverify_email&token=${rawToken}&username=${username}`
);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion spec/ValidationAndPasswordsReset.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
await user.signUp();

const verifyUserEmails = {
method: async (params) => {
method: async params => {
expect(params.object).toBeInstanceOf(Parse.User);
expect(params.ip).toBeDefined();
expect(params.master).toBeDefined();
Expand Down
10 changes: 4 additions & 6 deletions spec/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,8 @@ try {
// Fetch test exclusion list
testExclusionList = require('./testExclusionList.json');
console.log(`Using test exclusion list with ${testExclusionList.length} entries`);
} catch(error) {
if(error.code !== 'MODULE_NOT_FOUND') {
} catch (error) {
if (error.code !== 'MODULE_NOT_FOUND') {
throw error;
}
}
Expand All @@ -444,10 +444,8 @@ global.it_id = (id, func) => {
if (testExclusionList.includes(id)) {
return xit;
} else {
if(func === undefined)
return it;
else
return func;
if (func === undefined) return it;
else return func;
}
};

Expand Down
9 changes: 7 additions & 2 deletions src/Controllers/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class UserController extends AdaptableController {
master,
installationId,
ip,
resendRequest: true
resendRequest: true,
});
if (!shouldSend) {
return;
Expand All @@ -226,7 +226,12 @@ export class UserController extends AdaptableController {
if (!aUser || aUser.emailVerified) {
throw undefined;
}
const generate = await this.regenerateEmailVerifyToken(aUser, req.auth?.isMaster, req.auth?.installationId, req.ip);
const generate = await this.regenerateEmailVerifyToken(
aUser,
req.auth?.isMaster,
req.auth?.installationId,
req.ip
);
if (generate) {
this.sendVerificationEmail(aUser, req);
}
Expand Down
Loading
Loading