Commit Graph

931 Commits

Author SHA1 Message Date
Antonio Davi Macedo Coelho de Castro
8b97c1380b Batch transaction (#5849)
* Batch transaction boilerplate

* Refactoring transaction boilerplate

* Independent sessions test

* Transactions - partial

* Missing only one test

* All tests passing for mongo db

* Tests on Travis

* Transactions on postgres

* Fix travis to restart mongodb

* Remove mongodb service and keep only mongodb runner

* MongoDB service back

* Initialize replicaset

* Remove mongodb runner again

* Again only with mongodb-runner and removing cache

* Trying with pretest and posttest

* WiredTiger

* Pretest and posttest again

* Removing inexistent scripts

* wiredTiger

* One more attempt

* Trying another way to run mongodb-runner

* Fixing tests

* Include batch transaction on direct access

* Add tests to direct access
2019-07-31 02:41:07 -07:00
Lucas Alencar
6080dbc4f9 fix: Set falsy values as default to schema fields (#5868) 2019-07-30 15:51:49 -05:00
Diamond Lewis
218c3499f9 Implement WebSocketServer Adapter (#5866)
* Implement WebSocketServerAdapter

* lint

* clean up
2019-07-30 09:05:41 -05:00
Ivan SZKIBA
dfe0ff753c support PhantAuth authentication (#5850)
* support PhantAuth authentication

* fix spelling issues

* Add test case
2019-07-29 00:58:43 -05:00
Diamond Lewis
95208e96e0 Postgres: Safely escape strings in nested objects (#5855)
* Postgres: Safely handle string in nested objects

* fix failing tests
2019-07-28 23:54:13 -05:00
Antonio Davi Macedo Coelho de Castro
fd637ff4f8 Required fields and default values (#5835)
* 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
2019-07-25 21:13:59 -07:00
Omair Vaiyani
d3810c2eba GraphQL Configuration Options (#5782)
* 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
2019-07-25 12:46:25 -07:00
BrunoMaurice
50f1e8eb77 Make possible to alter response using the after save trigger (#5814)
* 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
2019-07-25 09:31:18 -07:00
Douglas Muraoka
4fe0ff6ebf feat: Add "count" to CLP initial value (#5841)
* feat: count CLP default values

* fix tests
2019-07-24 12:41:18 -05:00
Antonio Davi Macedo Coelho de Castro
b605638415 Fix: GraphQL _or operator not working (#5840) 2019-07-23 10:29:38 -03:00
Antonio Davi Macedo Coelho de Castro
2e0940c996 GraphQL @mock directive (#5836)
* Add mock directive
* Include tests for @mock directive
2019-07-22 15:19:40 -03:00
Antonio Davi Macedo Coelho de Castro
71d92aed8d GraphQL Custom Schema (#5821)
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"
      }
    }
  }
}
```
2019-07-18 16:43:49 -03:00
Antonio Davi Macedo Coelho de Castro
0b86a86209 GraphQL { functions { call } } generic mutation (#5818)
* Generic call function mutation
* Change function return type to any
* First passing test
* Testing errors
* Testing different data types
2019-07-18 16:41:10 -03:00
Douglas Muraoka
f91034ab8c GraphQL: Improve session token error messages (#5753)
* 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
2019-07-12 13:58:47 -07:00
Diamond Lewis
bb06376a32 Prevent linkWith sessionToken from generating new session (#5801) 2019-07-11 09:32:11 -05:00
Diamond Lewis
5341b8248f Generate sessionToken with linkWith (#5799)
* Generate sessionToken with linkWith

* improve test

* Add comment
2019-07-10 20:23:16 +00:00
Raschid J.F. Rafeally
9816285205 Added rest option: excludeKeys (#5737)
* Added restOption: excludeKeys

* improve tests
2019-07-10 15:01:21 -05:00
Diamond Lewis
378e70afdc Fix #5794 (#5797) 2019-07-10 15:19:40 -04:00
Arthur Cinader
76ce9e1a5c Run test that require db access (#5796)
as mongo only.

also seperate out into own section of test.
2019-07-10 12:25:29 -05:00
Arthur Cinader
815b7c6e05 Too much output! (#5795)
Reducing the spew.
2019-07-10 11:56:04 -04:00
Diamond Lewis
af6c44eca4 Handle LiveQuery create event with fields (#5790)
Close:  https://github.com/parse-community/parse-server/issues/5764

Fix logic handling null original object
2019-07-10 10:14:55 -05:00
Fabian Strachanski
73b0f9a339 Merge pull request from GHSA-8w3j-g983-8jh5
* Add Test and Authenticator for ghsa-8w3j-g983-8jh5

* fix for ghsa-8w3j-g983-8jh5

* nit whitespace

not sure why lint isn't catching...
2019-07-10 09:47:23 -04:00
Diamond Lewis
3a7b0c4c75 Fix: Linking with Apple Auth (#5755)
Rename from apple-signin to apple (key names can't have hyphens
Rename id_token to id (auth adapters require id)
2019-07-03 16:28:29 -05:00
Douglas Muraoka
2c4031092e GraphQL: /me pointers not working (#5745)
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.
2019-07-02 12:15:46 -07:00
Douglas Muraoka
3d63545ab7 GraphQL: User sign up required fields (#5743) 2019-07-02 12:11:45 -07:00
Diamond Lewis
e08f4f8023 Fix: Winston Logger string interpolation (#5729) 2019-06-25 18:01:00 -05:00
Antonio Davi Macedo Coelho de Castro
5bc79cc3db GraphQL support via cli (#5697)
* Including GraphQL options in CLI - now it was auto-generated

* Improving the way that the headers are passed to the playground

* Including README notes about GraphQL

* Improving final text
2019-06-25 14:44:23 -07:00
Diamond Lewis
7ffb3b65e0 Fix: eslint update to 6.0.1 (#5730) 2019-06-25 16:36:42 -05:00
Jeff Gu Kang
ad7fc48c97 Postgres: Regex support foreign characters (#5598)
* Fix issue #5293

* Fix issue #5293

* add test

* Revert "add test"

This reverts commit 38b32a627a9d2c9a9b852b48194f173d8b7254f3.

* fix conflicts

* use native package
2019-06-24 16:13:34 -05:00
Diamond Lewis
6385deeb6e Add AppSecret to Facebook Auth (#5695)
Closes: https://github.com/parse-community/parse-server/issues/5448
2019-06-20 14:15:57 -05:00
Antonio Davi Macedo Coelho de Castro
fe2e95622f 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
2019-06-19 17:19:47 -07:00
Jack Wearden
559096f1c2 Allow disabling workaround for since-fixed MongoDB bug (#5617)
* Allow disabling workaround for fixed MongoDB bug

* skipMongoDBServer13732Workaround description fix

* flip test boolean

* Remove CLI flag, use databaseVersion & engine

* Revert "Remove CLI flag, use databaseVersion & engine"

This reverts commit 042d1ba19f636fe0da06074168c6fd5db37ea048.

* clean up
2019-06-19 17:30:08 -05:00
Diamond Lewis
fcdf2d7947 Sign in with Apple Auth Provider (#5694)
* Sign in with Apple Auth Provider

Closes: https://github.com/parse-community/parse-server/issues/5632

Should work out of the box.

* remove required options
2019-06-19 16:05:09 -05:00
Antonio Davi Macedo Coelho de Castro
466a049bd0 Fix ttl flaky test (#5686) 2019-06-13 15:06:16 -05:00
Diamond Lewis
7590ee9799 Fix #5678 (#5681)
* Fix #5678

* Revert "Fix #5678"

This reverts commit 106b6ddd9535da6ec323226c1b9ad649022aeb1e.

* revert #5627
2019-06-13 13:40:58 -05:00
Antonio Davi Macedo Coelho de Castro
8b667cf048 Fix 5651 (#5684)
* Fix 5651

* Fix User initilization test
2019-06-13 13:40:38 -05:00
Diamond Lewis
8709daf698 Merge pull request from GHSA-2479-qvv7-47qq
* Failing test

* provide fix

* clearer test

* failing expect
2019-06-12 16:12:11 -05:00
Diamond Lewis
cb2b60bd90 Flaky Test (#5670) 2019-06-11 19:54:23 -05:00
Diamond Lewis
5d8b1535ac Flaky Tests (#5668)
Properly cleanup cache and database between tests. This includes indexes.
2019-06-11 16:31:27 -07:00
Diamond Lewis
d13bdbcea6 Flaky Tests (#5666)
Closes: https://github.com/parse-community/parse-server/issues/5651

Building on https://github.com/parse-community/parse-server/pull/5551
2019-06-11 14:05:32 -05:00
Diamond Lewis
7a080478b5 Fix #5654 (#5664)
* Fix #5654

* fix tests

* throw error instead
2019-06-11 13:40:34 -05:00
Olivier Allouch
7fc0d45b89 Database version in features (#5627)
* adding database.version in the serverInfo (only MongoDB, it gives undefined when using Postgres)

* . correction of old 'features' tests
. adding engine and database in the StorageAdapter interface and implementations

* . version retrieval done in performInitialization
. PostgreSQL version

* performInitialization now returns a Promise
2019-06-03 16:58:21 -05:00
Diamond Lewis
cc6d474dcb Schema Cache Improvement 2 (#5616)
* schema hasClass improvement

* create object improvement

* destroy object

* update object

* hasClass test rewrite

* more tests

* improve signing up users
2019-05-30 11:14:05 -05:00
Diamond Lewis
f7716f2f87 Schema Cache Improvements (#5612)
* Cache Improvements

* improve tests

* more tests

* clean-up

* test with singlecache

* ensure indexes exists

* remove ALL_KEYS

* Add Insert Test

* enableSingleSchemaCache default true

* Revert "enableSingleSchemaCache default true"

This reverts commit 323e7130fb8f695e3ca44ebf9b3b1d38905353da.

* further optimization

* refactor enforceFieldExists

* coverage improvements

* improve tests

* remove flaky test

* cleanup

* Learned something new
2019-05-24 16:42:27 -05:00
dependabot[bot]
e9b8752c3f Bump mongodb from 3.2.4 to 3.2.5 (#5604)
* Bump mongodb from 3.2.4 to 3.2.5

Bumps [mongodb](https://github.com/mongodb/node-mongodb-native) from 3.2.4 to 3.2.5.
- [Release notes](https://github.com/mongodb/node-mongodb-native/releases)
- [Changelog](https://github.com/mongodb/node-mongodb-native/blob/master/HISTORY.md)
- [Commits](https://github.com/mongodb/node-mongodb-native/compare/v3.2.4...v3.2.5)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Tweak expected error message in a test to match a change
in the underlying package.
see: https://github.com/mongodb-js/mongodb-core/commit/83e224b

cc: @davimacedo
2019-05-21 22:33:31 +00:00
Antonio Davi Macedo Coelho de Castro
2da2a27373 Fixing Redis adapter tests (#5599) 2019-05-16 15:26:45 -07:00
Antonio Davi Macedo Coelho de Castro
afa74d655d Futzing with read preference (#3963)
* allow setting readpreference when using rest api.

* take out partially complete unit test.

* oops. nit

* Include read preference option for find directly from api and adding few more tests

* Adding catch for all tests

* Keep same check for get and find

* Turn read preference case insensitive

* Includes and subqueries read preferences through API

* Fixing bugs regarding changes that were done in master branch during the last year

* Changing behavior to make includeReadPreference and subqueryReadPreference to follow readPreference by default
2019-05-14 12:58:02 -07:00
Antonio Davi Macedo Coelho de Castro
893f1d376e Remove test delays (#5579)
* Changing __indexBuildCompletionCallbackForTests callback to serverStartComplete

* Improving serverStartComplete callback to avoid production unhandled promise rejection

* Add test to check inexistence of unhandled promise rejection on server fail

* Removing some hooks delays

* Removing delay after reconfigureServer

* Improving code style
2019-05-14 11:34:51 -07:00
Diamond Lewis
0ce4eeae72 LiveQuery: Add options for Redis (#5584)
Closes: https://github.com/parse-community/parse-server/issues/5387
2019-05-11 19:13:41 -05:00
Antonio Davi Macedo Coelho de Castro
90c81c1750 Validates permission before calling beforeSave trigger (#5546)
* Test to reproduce the problem

* Validating update before calling beforeSave trigger

* Fixing lint

* Commenting code

* Improving the code
2019-05-11 10:37:27 -07:00