Skip to content

Commit fe2e956

Browse files
authored
GraphQL Support (#5674)
* GraphQL boilerplate * Create GraphQL schema without using gql * Introducing loaders * Generic create mutation * create mutation is now working for any data type * Create mutation for each parse class - partial * Adding more data types to the class * Get parse class query * Generic get query * Generic delete mutation * Parse class delete mutation * Parse class find mutation * Generic update mutation * Parse class update mutation * Fixing initialization problems * Installing node-fetch again * Basic implementation for Pointer * Constructor tests * API tests boilerplate * _getGraphQLOptions * applyGraphQL tests * GraphQL API initial tests * applyPlayground tests * createSubscriptions tests * ParseGrapjQLSchema tests file * ParseGraphQLSchema tests * TypeValidationError * TypeValidationError * parseStringValue test * parseIntValue tests * parseBooleanValue tests * parseDateValue tests * parseValue tests * parseListValues tests * parseObjectFields tests * Default types tests * Get tests * First permission test at generic Get operation * Fixing prepare data * ApolloClient does not work well with different queries runnning in paralell with different headers * ApolloClient does not work well with different queries runnning in paralell with different headers * User 3 tests * User 3 tests * Get level permission tests * Get User specific tests * Get now support keys argument * Get now supports include argument * Get now supports read preferences * Adding tests for read preference enum type * Find basic test * Find permissions test * Find where argument test * Order, skip and limit tests * Error handler * Find now supports count * Test for FindResult type * Improving find count * Find max limit test * Find now supports keys, include and includeAll * Find now supports read preferences * Basic Create test * Generic create mutation tests * Basic update test * UpdateResult object type test * Update level permissions tests * Error handler for default mutations * Delete mutation basic test * Delete mutation level permission tests * Test for string * String test * Date test * Pointer test * Relation tests * Changing objects mutations location * Changing objects queries location * Create file mutation * Test for file fields * Test for null values * Changing parse classes operations location * Objects mutations refactoring * Class specific create object mutation now working * Update class specific mutation now working * Specific class delete mutation now working * Get class specific mutation now working * Find class specific query now working without where and sort * Find query for custom classes working with where partially * Almost all data types working for specfic class find where * Now only missing relation, geopoint, file and ACL * Additional tests with Parse classes queries and mutations * Now only missing relation, geopoint, file and ACL * Files * Fiels are now working * Excluding missing order test temporarly * Refactoring dates * Refactoring files * Default types review * Refeactoring object queries * Refactoring class scalar type * Refactoring class types * Geo queries are now working * Fixing centerSphere * Allow sort on class specific queries * Supporting bytes * ACL constraint * Temporarly removing xit tests * Fixing some tests because of schema cache * Removing session token from users * Parse.User queries and mutations * Remove test using fit * Fixing include test that was failing because of schema cache * Fixing count test for postgres. Postgres does not count with where={} (legacy problem). We should solve it later * Fix null values test for postgres. It is evaluating null as undefined (legacy problem) and we should fix is later. * Fixing schema change test that was failing because of schema cache * Add GraphQL File type parseLiteral tests * Refeactoring users * Including sign up mutation * Fix failing test * Improve default GraphQL types tests coverage * Including some tests for data types * Including additional pointer test: * Fixing some tests * more data type tests * Include Bytes and Polygon data types tests * Polygons test * Merging other tests * Fixing some postgres tests
1 parent 922251a commit fe2e956

20 files changed

+9532
-5
lines changed

package-lock.json

+868-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+16
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,22 @@
1919
],
2020
"license": "BSD-3-Clause",
2121
"dependencies": {
22+
"@apollographql/graphql-playground-html": "1.6.6",
2223
"@parse/fs-files-adapter": "1.0.1",
2324
"@parse/push-adapter": "3.0.0",
2425
"@parse/s3-files-adapter": "1.2.1",
2526
"@parse/simple-mailgun-adapter": "1.1.0",
27+
"apollo-server-express": "2.4.8",
2628
"bcryptjs": "2.4.3",
2729
"body-parser": "1.19.0",
2830
"commander": "2.20.0",
31+
"cors": "2.8.5",
2932
"deepcopy": "2.0.0",
3033
"express": "4.17.1",
3134
"follow-redirects": "1.7.0",
35+
"graphql": "14.2.1",
36+
"graphql-list-fields": "2.0.2",
37+
"graphql-upload": "8.0.5",
3238
"intersect": "1.0.1",
3339
"jsonwebtoken": "8.5.1",
3440
"lodash": "4.17.11",
@@ -40,6 +46,7 @@
4046
"pg-promise": "8.7.2",
4147
"redis": "2.8.0",
4248
"semver": "6.1.1",
49+
"subscriptions-transport-ws": "0.9.16",
4350
"tv4": "1.3.0",
4451
"uuid": "3.3.2",
4552
"winston": "3.2.1",
@@ -53,13 +60,21 @@
5360
"@babel/plugin-transform-flow-strip-types": "7.4.4",
5461
"@babel/preset-env": "7.4.5",
5562
"@parse/minami": "1.0.0",
63+
"apollo-cache-inmemory": "1.5.1",
64+
"apollo-client": "2.5.1",
65+
"apollo-link": "1.2.11",
66+
"apollo-link-http": "1.5.14",
67+
"apollo-link-ws": "1.0.17",
68+
"apollo-upload-client": "10.0.0",
69+
"apollo-utilities": "1.2.1",
5670
"babel-eslint": "10.0.2",
5771
"bcrypt-nodejs": "0.0.3",
5872
"cross-env": "5.2.0",
5973
"deep-diff": "1.0.2",
6074
"eslint": "5.16.0",
6175
"eslint-plugin-flowtype": "3.10.3",
6276
"flow-bin": "0.101.0",
77+
"form-data": "2.3.3",
6378
"gaze": "1.1.3",
6479
"husky": "2.4.1",
6580
"jasmine": "3.4.0",
@@ -68,6 +83,7 @@
6883
"jsdoc-babel": "0.5.0",
6984
"lint-staged": "8.2.1",
7085
"mongodb-runner": "4.3.2",
86+
"node-fetch": "2.5.0",
7187
"nyc": "14.1.1",
7288
"prettier": "1.18.2",
7389
"supports-color": "7.0.0"

spec/.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"range": true,
2525
"jequal": true,
2626
"create": true,
27-
"arrayContains": true
27+
"arrayContains": true,
28+
"expectAsync": true
2829
},
2930
"rules": {
3031
"no-console": [0],

spec/ParseGraphQLSchema.spec.js

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
const defaultLogger = require('../lib/logger').default;
2+
const { ParseGraphQLSchema } = require('../lib/GraphQL/ParseGraphQLSchema');
3+
4+
describe('ParseGraphQLSchema', () => {
5+
let parseServer;
6+
let databaseController;
7+
let parseGraphQLSchema;
8+
9+
beforeAll(async () => {
10+
parseServer = await global.reconfigureServer({
11+
schemaCacheTTL: 100,
12+
});
13+
databaseController = parseServer.config.databaseController;
14+
parseGraphQLSchema = new ParseGraphQLSchema(
15+
databaseController,
16+
defaultLogger
17+
);
18+
});
19+
20+
describe('constructor', () => {
21+
it('should require a databaseController and a log instance', () => {
22+
expect(() => new ParseGraphQLSchema()).toThrow(
23+
'You must provide a databaseController instance!'
24+
);
25+
expect(() => new ParseGraphQLSchema({})).toThrow(
26+
'You must provide a log instance!'
27+
);
28+
expect(() => new ParseGraphQLSchema({}, {})).not.toThrow();
29+
});
30+
});
31+
32+
describe('load', () => {
33+
it('should cache schema', async () => {
34+
const graphQLSchema = await parseGraphQLSchema.load();
35+
expect(graphQLSchema).toBe(await parseGraphQLSchema.load());
36+
await new Promise(resolve => setTimeout(resolve, 200));
37+
expect(graphQLSchema).toBe(await parseGraphQLSchema.load());
38+
});
39+
40+
it('should load a brand new GraphQL Schema if Parse Schema changes', async () => {
41+
await parseGraphQLSchema.load();
42+
const parseClasses = parseGraphQLSchema.parseClasses;
43+
const parseClassesString = parseGraphQLSchema.parseClasses;
44+
const parseClassTypes = parseGraphQLSchema.parseClasses;
45+
const graphQLSchema = parseGraphQLSchema.parseClasses;
46+
const graphQLTypes = parseGraphQLSchema.parseClasses;
47+
const graphQLQueries = parseGraphQLSchema.parseClasses;
48+
const graphQLMutations = parseGraphQLSchema.parseClasses;
49+
const graphQLSubscriptions = parseGraphQLSchema.parseClasses;
50+
const newClassObject = new Parse.Object('NewClass');
51+
await newClassObject.save();
52+
await databaseController.schemaCache.clear();
53+
await new Promise(resolve => setTimeout(resolve, 200));
54+
await parseGraphQLSchema.load();
55+
expect(parseClasses).not.toBe(parseGraphQLSchema.parseClasses);
56+
expect(parseClassesString).not.toBe(parseGraphQLSchema.parseClasses);
57+
expect(parseClassTypes).not.toBe(parseGraphQLSchema.parseClasses);
58+
expect(graphQLSchema).not.toBe(parseGraphQLSchema.parseClasses);
59+
expect(graphQLTypes).not.toBe(parseGraphQLSchema.parseClasses);
60+
expect(graphQLQueries).not.toBe(parseGraphQLSchema.parseClasses);
61+
expect(graphQLMutations).not.toBe(parseGraphQLSchema.parseClasses);
62+
expect(graphQLSubscriptions).not.toBe(parseGraphQLSchema.parseClasses);
63+
});
64+
});
65+
});

0 commit comments

Comments
 (0)