* Add test case for order option when extending the schema
* Remove fit
* upgrade to graphql-tools v5
revert #6515
Co-authored-by: Antonio Davi Macedo Coelho de Castro <adavimacedo@gmail.com>
* Allow real GraphQL Schema via ParseServer.start
* wip
* working
* tests ok
* add tests about enum/input use case
* Add async function based merge
* Better naming
* remove useless condition
* fix(GraphQL): Unable to run queries with order as array
An internal server error is thrown if the `order` query parameter is an array.
Currently, `order` only works with a single value.
* Add tests
* Reset cache
* Remove one of the tests from Postgres
Co-authored-by: Douglas Muraoka <douglas.muraoka@gmail.com>
* Suppress Test Logs
This will reduce some of the noise in the tests logs.
* replace deprecated buffer
* remove deprecation warnings
* fix geopoint
* Fix GraphQL
* postgres warnings
* Install graphql-relay
* Add relayNodeInterface to ParseGraphQLSchema
* Add support to global id
* Add support to global id in other operations
* Fix sort by glboal id
* Fix where by global id
* Introduce IdWhereInput
* Add Relay object identification tests
* Client mutation id on createFile mutation
* Client mutation id on callCloudCode mutation
* Client mutation id on signUp mutation
* Client mutation id on logIn mutation
* Client mutation id on logOut mutation
* Client mutation id on createClass mutation
* Client mutation id on updateClass mutation
* Client mutation id on deleteClass mutation
* Client mutation id on create object mutation
* Improve Viewer type
* Client mutation id on update object mutation
* Client mutation id on delete object mutation
* Introducing connections
* Fix tests
* Add pagination test
* Fix file location
* Fix postgres tests
* Add comments
* Tests to calculateSkipAndLimit
* refactor(GraphQL): Pointer constraint input type as ID
Redefines the Pointer constraint input type from a custom scalar to
a simple ID.
* fix: PR review requested changes
* Remove nested operations
* Improve error log
* Fix bug schema to load
* Fix ParseGraphQLSchema tests
* Fix tests
* Fix failing tests
* First verstion not complete of create class mutation
* Fix bug caused by circular dependency
* Renaming files
* Schema types should be loaded before parse classes
* Fix tests
* Create class mutation boilerplate
* Improve CreateClassSchemaInput fields names
* Remove fields
* Pointer and relation fields
* Improve pointer default type
* Class type
* Create class mutation resolver
* Schema field transformers
* Class types transformations
* First test
* Numbers test
* Boolean tests
* Date test
* Fix some get tests
* Test for created at and updated at
* File tests
* Test for objects
* Renaming reducerFabric to reducerGenerator
* Changing get tests for file and object
* Object composed queries test
* Array test
* Null field test
* Bytes test
* Geo Point test
* Polygons tests
* Remove create generic mutation
* Fix tests
* Create class test - isRequired and defaultValue will be added back later
* Enforce master key
* Fix tests
* Duplicated field test
* updateClass mutation
* Remove update generic mutation tests
* Remove update generic mutation
* deleteClass mutation
* Remove delete generic mutation tests
* Remove delete generic mutation
* class query
* Classes query
* Remove get generic query from tests
* Remove remaining generic operations and fix tests
* Fix last test
* Try to fix redis tests
* Fix postgres tests
* Update objectsMutations and objectsQueries files locations
* Rename classSchema files to schema files
* Rename ClassObject to ParseObject
* Fix names and paths
* Still some wrong names
* refactor(GraphQL): Rename objectId to id
Renames `objectId` to `id` for the GraphQL API. Queries, mutations,
custom and generic types were updated.
Removes `RELATION_INPUT` and `POINTER_INPUT`. Now the user just need
to provide the ID of the object to link.
* fix: Column "id" not found on Postgres
* fix: Avoid deleting Parse class objectId
* fix: Undo objectId removal on mutations
* fix: Handle generic mutation id
* Add a test on deep complex GraphQL Query
* Relation/Pointer new DX + deep nested mutations
* Fix lint
* Review
* Remove unnecessary code
* Fix objectId on update
* Renaming GraphQL Types/Inputs
* Add Native Type to avoid collision
* Use pluralize for renaming
* Fixing tests
* Improve name collision management - tests passsing
* Renaming few more default types
* Rename file input
* Reverting fields types to not collide with the relay spec types
Improver users mutations
* Adding ArrayResult to the reserved list
* Fixing tests
* Add more unit tests to ParseGraphQLSchema
* Test transformClassNameToGraphQL
* Name collision tests
* fix(package): update mongodb to version 3.3.0
* chore(package): update lockfile package-lock.json
* Fix tests
* Fix GraphQL tests for read preference
* Fix mongo adapter deprecation notice
* Fix the way the connections are checked, return promise when shutting down mongo
* GraphQL Object constraints
Implements the GraphQL Object constraints, which allows us to filter queries results using the `$eq`, `$lt`, `$gt`, `$in`, and other Parse supported constraints.
Example:
```
query objects {
findMyClass(where: {
objField: {
_eq: {
key: 'foo.bar',
value: 'hello'
},
_gt: {
key: 'foo.number',
value: 10
},
_lt: {
key: 'anotherNumber',
value: 5
}
}
}) {
results {
objectId
}
}
}
```
In the example above, we have the `findMyClass` query (automatically generated for the `MyClass` class), and a field named `objField` whose type is Object. The object below represents a valid `objField` value and would satisfy all constraints:
```
{
"foo": {
"bar": "hello",
"number": 11
},
"anotherNumber": 4
}
```
The Object constraint is applied only when using Parse class object type queries. When using "generic" queries such as `get` and `find`, this type of constraint is not available.
* Objects constraints not working on Postgres
Fixes the $eq, $ne, $gt, and $lt constraints when applied on an Object type field.
* Fix object constraint field name
* Fix Postgres constraints indexes
* fix: Object type composed constraints not working
* fix: Rename key and value fields
* refactor: Object constraints for generic queries
* fix: Object constraints not working on Postgres
* 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
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"
}
}
}
}
```
* 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
When using the `/me` endpoint to fetch the current user, it does not fetches data from any Pointer data type field, even though the field was defined in the GraphQL schema.
* 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