* fix(package): update @parse/push-adapter to version 3.0.5
* chore(package): update lockfile package-lock.json
* Update flow-bin to the latest version 🚀 (#5853)
* chore(package): update flow-bin to version 0.104.0
* chore(package): update lockfile package-lock.json
* Update package.json
* Pin to 3.0.8
* Add field options to mongo schema metadata
* Add/fix test with fields options
* Add required validation failing test
* Add more tests
* Only set default value if field is undefined
* Fix redis test
* Fix tests
* Test for creating a new class with field options
* Validate default value type
* fix lint (weird)
* Fix lint another way
* Add tests for beforeSave trigger and solve small issue regarding the use of unset in the beforeSave trigger
* add parse-graph-ql configuration for class schema customisation
Not yet tested - essentially an RFC
* refactor and add graphql router, controller and config cache
* fix(GraphQLController): add missing check isEnabled
* chore(GraphQLController): remove awaits from cache put
* chore(GraphQLController): remove check for if its enabled
* refactor(GraphQLController): only use cache if mounted
* chore(GraphQLController): group all validation errors and throw at once
* chore(GraphQLSchema): move transformations into controller validation
* refactor(GraphQL): improve ctrl validation and fix schema usage of config
* refactor(GraphQLSchema): remove code related to additional schema
This code has been moved into a separate feature branch.
* fix(GraphQLSchema): fix incorrect default return type for class configs
* refactor(GraphQLSchema): update staleness check code to account for config
* fix(GraphQLServer): fix regressed tests due to internal schema changes
This will be followed up with a backwards compatability fix for the `ClassFields` issue to avoid breakages for our users
* refactor: rename to ParseGraphQLController for consistency
* fix(ParseGraphQLCtrl): numerous fixes for validity checking
Also includes some minor code refactoring
* chore(GraphQL): minor syntax cleanup
* fix(SchemaController): add _GraphQLConfig to volatile classes
* refactor(ParseGraphQLServer): return update config value in setGraphQLConfig
* testing(ParseGraphQL): add test cases for new graphQLConfig
* fix(GraphQLController): fix issue where config with multiple items was not being mapped to the db
* fix(postgres): add _GraphQLConfig default schema on load
fixes failing postgres tests
* GraphQL @mock directive (#5836)
* Add mock directive
* Include tests for @mock directive
* Fix existing tests due to the change from ClassFields to ClassCreateFields
* fix(parseClassMutations): safer type transformation based on input type
* fix(parseClassMutations): only define necessary input fields
* fix(GraphQL): fix incorrect import paths
* make possible to alter response using the after save trigger like for after find
* code clearing to follow same object checking
* remove console log debug
* fix test unit
* custom pages example and an email adapter is added
* npm link of email adapter
* spelling and grammar changes
Co-Authored-By: Tom Fox <tomfox@surprises.io>
* spelling changes
Co-Authored-By: Tom Fox <tomfox@surprises.io>
* Add --graphQLSchema to CLI
* Add custom graphql schema instructions to readme file
* Update README.md
Co-Authored-By: Tom Fox <tomfox@surprises.io>
* Update src/Options/Definitions.js
Co-Authored-By: Tom Fox <tomfox@surprises.io>
* Update src/Options/docs.js
Co-Authored-By: Tom Fox <tomfox@surprises.io>
* Update src/Options/index.js
Co-Authored-By: Tom Fox <tomfox@surprises.io>
This PR empowers the Parse GraphQL API with custom user-defined schema. The developers can now write their own types, queries, and mutations, which will merged with the ones that are automatically generated. The new types are resolved by the application's cloud code functions.
Therefore, regarding https://github.com/parse-community/parse-server/issues/5777, this PR closes the cloud functions needs and also addresses the graphql customization topic. In my view, I think that this PR, together with https://github.com/parse-community/parse-server/pull/5782 and https://github.com/parse-community/parse-server/pull/5818, when merged, closes the issue.
How it works:
1. When initializing ParseGraphQLServer, now the developer can pass a custom schema that will be merged to the auto-generated one:
```
parseGraphQLServer = new ParseGraphQLServer(parseServer, {
graphQLPath: '/graphql',
graphQLCustomTypeDefs: gql`
extend type Query {
custom: Custom @namespace
}
type Custom {
hello: String @resolve
hello2: String @resolve(to: "hello")
userEcho(user: _UserFields!): _UserClass! @resolve
}
`,
});
```
Note:
- This PR includes a @namespace directive that can be used to the top level field of the nested queries and mutations (it basically just returns an empty object);
- This PR includes a @resolve directive that can be used to notify the Parse GraphQL Server to resolve that field using a cloud code function. The `to` argument specifies the function name. If the `to` argument is not passed, the Parse GraphQL Server will look for a function with the same name of the field;
- This PR allows creating custom types using the auto-generated ones as in `userEcho(user: _UserFields!): _UserClass! @resolve`;
- This PR allows to extend the auto-generated types, as in `extend type Query { ... }`.
2. Once the schema was set, you just need to write regular cloud code functions:
```
Parse.Cloud.define('hello', async () => {
return 'Hello world!';
});
Parse.Cloud.define('userEcho', async req => {
return req.params.user;
});
```
3. Now you are ready to play with your new custom api:
```
query {
custom {
hello
hello2
userEcho(user: { username: "somefolk" }) {
username
}
}
}
```
should return
```
{
"data": {
"custom": {
"hello": "Hello world!",
"hello2": "Hello world!",
"userEcho": {
"username": "somefolk"
}
}
}
}
```
* chore(package): update @babel/cli to version 7.5.5
* chore(package): update @babel/core to version 7.5.5
* chore(package): update @babel/plugin-proposal-object-rest-spread to version 7.5.5
* chore(package): update @babel/preset-env to version 7.5.5
* chore(package): update lockfile package-lock.json
* GraphQL: Improve session token error message
Fixes the session token related error messages during GraphQL operations. If any authentication error were thrown, it was not correctly handled by the GraphQL express middleware, and ended responding the request with a JSON parsing error.
* Refactor handleError usage
* Use handleParseErrors middleware to handle invalid session token error
* fix: Status code 400 when session token is invalid
* fix: Undo handleParseErrors middleware change