Commit Graph

55 Commits

Author SHA1 Message Date
Prerna Mehra
5d9bf24b02 GraphQL: reset password with emailed token (#7290)
* renamed "resetPassword" to "requestResetPassword" & created new "resetPassword" mutation

* added new route to handle resetPassword in UsersRouter.js

* updated resetPassword test to "requestResetPassword" mutation

* updated "resetPassword" mutation args description

* changed token arg description to rerun the tests

* directly using updatePassword for resetPassword

* removed handleResetPassword from UsersRouter.js file

* added test case for reset Password

* changed mutation names to "resetPassword" & "confirmResetPassword"

* changed mutation names in test also
2021-03-28 21:45:41 -07:00
Chris
6313656d8a Excluding keys that have trailing "edges.node" on them (#7273)
* Excluding keys that have trailing "edges.node" on them as they will not be selectable anyway

* Updated CHANGELOG and added test case

* Forgot to change fit back to it
2021-03-17 20:40:11 -07:00
Diamond Lewis
a02014f557 Improve single schema cache (#7214)
* Initial Commit

* fix flaky test

* temporary set ci timeout

* turn off ci check

* fix postgres tests

* fix tests

* node flaky test

* remove improvements

* Update SchemaPerformance.spec.js

* fix tests

* revert ci

* Create Singleton Object

* properly clear cache testing

* Cleanup

* remove fit

* try PushController.spec

* try push test rewrite

* try push enqueue time

* Increase test timeout

* remove pg server creation test

* xit push tests

* more xit

* remove skipped tests

* Fix conflicts

* reduce ci timeout

* fix push tests

* Revert "fix push tests"

This reverts commit 05aba62f1cbbca7d5d3e80b9444529f59407cb56.

* improve initialization

* fix flaky tests

* xit flaky test

* Update CHANGELOG.md

* enable debug logs

* Update LogsRouter.spec.js

* create initial indexes in series

* lint

* horizontal scaling documentation

* Update Changelog

* change horizontalScaling db option

* Add enableSchemaHooks option

* move enableSchemaHooks to databaseOptions
2021-03-16 16:05:36 -05:00
Diamond Lewis
1666c3e382 [WIP] Enable test suite to be randomized (#7265)
* initial run

* Update ParseGraphQLServer.spec.js

* temporarily enable reporter

* Bump retry limit

* fix undefined database

* try to catch error

* Handle LiveQueryServers

* Update Config.js

* fast-fail false

* Remove usage of AppCache

* oops

* Update contributing guide

* enable debugger, try network retry attempt 1

* Fix ldap unbinding

* move non specs to support

* add missing mock adapter

* fix Parse.Push

* RestController should match batch.spec.js

* Remove request attempt limit

* handle index.spec.js

* Update CHANGELOG.md

* Handle error: tuple concurrently updated

* test transactions

* Clear RedisCache after every test

* LoggerController.spec.js

* Update schemas.spec.js

* finally fix transactions

* fix geopoint deadlock

* transaction with clean database

* batch.spec.js
2021-03-15 02:04:09 -05:00
Diamond Lewis
9563793303 Allow single server instance in test suite (#7262)
* initial pass

* reconfigureServer when needed

* finish postgres tests

* mongo tests

* more tests

* clean up

* re-add skipped test

* Fix transaction tests

* handle batch

* AuthenticationAdapter fix

* More reconfiguration

* clean up

* properly terminate cli servers

* handle Parse.Push

* Flaky PushController

* ensure reconfigureServer when changed

* fix postgres tests

* remove console.log

* LiveQuery spec remove duplicates and listeners
2021-03-13 09:05:22 -06:00
Antoine Cormouls
b398894341 Remove viewer from logout (#7029) 2020-12-07 15:45:51 -08:00
Diamond Lewis
e6ac3b6932 fix(prettier): Properly handle lint-stage files (#6970)
Now handles top level files and recursive files in folders.

Set max line length to be 100
2020-10-25 15:06:58 -05:00
Antoine Cormouls
5693470101 transform input types also on user mutations (#6934) 2020-10-09 08:40:30 -07:00
Diamond Lewis
a0ac8e0686 Remove Facebook AccountKit auth (#6870)
* Remove Facebook AccountKit auth

Account Kit services are no longer available.

https://developers.facebook.com/blog/post/2019/09/09/account-kit-services-no-longer-available-starting-march/

https://www.sinch.com/blog/facebook-account-kit-is-closing-down-are-your-apps-covered/

* remove flaky test
2020-08-20 10:09:54 -07:00
Antoine Cormouls
78239ac907 Merge pull request from GHSA-236h-rqv8-8q73
* Fix graphql viewer breach

* fix

* remove comment
2020-07-17 09:50:41 -07:00
Yaacov Rydzinski
f56049b34b upgrade graphql-tools to v6 (#6701)
* upgrade to v6

* remove old graphql-tools package

Co-authored-by: Antonio Davi Macedo Coelho de Castro <adavimacedo@gmail.com>
2020-05-24 23:35:45 -07:00
greenkeeper[bot]
b1506995ad Update uuid to the latest version 🚀 (#6659)
* fix(package): update uuid to version 8.0.0

* chore(package): update lockfile package-lock.json

* remove deprecated uuid/v4

* use uuidv4 as default

Co-authored-by: greenkeeper[bot] <23040076+greenkeeper[bot]@users.noreply.github.com>
Co-authored-by: Diamond Lewis <findlewis@gmail.com>
2020-04-30 05:21:51 +00:00
Antoine Cormouls
4d1bd9346f Allow to unset file from graphql (#6651) 2020-04-29 22:18:25 -07:00
Antoine Cormouls
f2f772084f Allow to resolve automatically Parse Type fields from Custom Schema (#6562)
* add package

* Allow real GraphQL Schema via ParseServer.start

* Allow resolve fields from auto graphQL Schema

* Simple merge

* fix + improve

* Add tests
2020-04-21 10:15:00 -07:00
Yaacov Rydzinski
a6300a2201 Graphql tools v5 (#6611)
* 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>
2020-04-20 22:16:48 -07:00
Antoine Cormouls
312a4bc812 Switch ACL to Relay Global Id (#6495) 2020-03-23 01:35:42 -07:00
Antoine Cormouls
16a974a04a Fix Unknow type merge bug on overloaded types (#6494)
* Fix Unknow type bug on overloaded types

* check args too
2020-03-11 12:59:18 -07:00
Antoine Cormouls
c7f96c92cd GraphQL: Allow true GraphQL Schema Customization (#6360)
* 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
2020-02-21 15:12:49 -08:00
Old Grandpa
292bdb713a Allow protectedFields for Authenticated users and Public. Fix userField with keys/excludedKeys (#6415)
* fix error message and test it

* protected fields fixes

* clean

* remove duplicate test, add some comments

* no need for 'requiresAuthentication'
2020-02-19 01:34:08 -08:00
Antoine Cormouls
30a5aa0b61 GraphQL: Nested File Upload (#6372)
* wip

* wip

* tested

* wip

* tested
2020-01-27 19:16:53 -08:00
Antoine Cormouls
df3fa029bc fix queries (#6363) 2020-01-27 19:10:39 -08:00
Antoine Cormouls
d4e264daf8 GraphQL: 3rd Party LoginWith Support (#6371)
* wip

* wip

* tested
2020-01-27 18:57:26 -08:00
Antonio Davi Macedo Coelho de Castro
4107a59063 Add tests for ordering by multiple fields (#6316)
* 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>
2020-01-05 22:15:37 -08:00
Antoine Cormouls
576631f09e Reset and Send verification email (#6301) 2020-01-04 12:50:00 -08:00
Antoine Cormouls
a72ab50c70 GraphQL: Support required fields on output type (#6279)
* Handle required fields

* Fix output fields
2019-12-14 20:12:04 -08:00
Antoine Cormouls
e0e06ef131 Handle required fields (#6271) 2019-12-11 21:47:11 -08:00
Antoine Cormouls
5d76b2f354 GraphQL: DX Relational Where Query (#6255)
* DX Relational Where Query

* Remove WherePointer & fix tests

* Add have, haveNot, exists on Pointer/Relation where input

* Merge branch 'master' into gql-relational-query

* Enable inQueryKey

* better descrption
2019-12-05 10:14:16 -08:00
Diamond Lewis
985933955f Suppress Test Logs (#6256)
* 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
2019-12-03 18:21:12 -06:00
Antonio Davi Macedo Coelho de Castro
a9066e20dc Relay Spec (#6089)
* 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
2019-12-01 21:43:08 -08:00
Antoine Cormouls
2290145e82 GraphQL: ACL (#5957)
* Spec

Fix Spec

* Add ACL Type + Input

* Improvements

* Fix
2019-10-01 21:47:56 -07:00
Antonio Davi Macedo Coelho de Castro
1361bb3020 Introduce ReadOptionsInput (#6030) 2019-09-12 13:43:49 -07:00
Antonio Davi Macedo Coelho de Castro
a754b883b2 Improve callCloudCode mutation to receive a CloudCodeFunction enum instead of a String (#6029)
* Add listing test

* Improvements

* Fixinf package.json

* Fix package.json

* Fix tests
2019-09-09 15:07:22 -07:00
Douglas Muraoka
f9b77c1bc7 refactor(GraphQL): Pointer constraint input type as ID (#6020)
* 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
2019-09-04 15:46:18 -07:00
Antonio Davi Macedo Coelho de Castro
34f1bf384d GraphQL: Remove underline from operators (#6024)
* Change _or, _and, _nor to OR, AND, NOR

* Renaming where operators maps

* Fix tests

* Fix tests

* Remove CreateResult and UpdateResult types

* Remove KEYS_ATT and INCLUDE_ATT

* Full text search test

* Change the operation generator functions names

* Fix object constraints

* Improve constraint transformation
2019-09-04 10:57:51 -07:00
Antonio Davi Macedo Coelho de Castro
5a482bd661 GraphQL schema operations (#5993)
* 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
2019-09-01 22:11:03 -07:00
Douglas Muraoka
b47d9fb17e refactor(GraphQL): Rename objectId to id (#5985)
* 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
2019-08-30 16:23:45 -07:00
Antoine Cormouls
5b3a492965 GraphQL DX: Relation/Pointer (#5946)
* 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
2019-08-21 14:55:34 -07:00
Antonio Davi Macedo Coelho de Castro
f5ac94ddb2 Fix GraphQL max upload size (#5940) 2019-08-19 01:23:59 -05:00
Antonio Davi Macedo Coelho de Castro
ee5aeeaff5 Remove nested operations from GraphQL API (#5931)
* Remove nested operations

* Improve error log

* Fix bug schema to load

* Fix ParseGraphQLSchema tests

* Fix tests

* Fix failing tests

* Rename call to callCloudCode
2019-08-17 20:02:19 +02:00
Antoine Cormouls
cea1988ce9 GraphQL: Fix undefined Array (#5926)
* Add Spec

* Fix Undefined Array

* Nullability policy
2019-08-16 11:12:29 -07:00
Antoine Cormouls
59b0221fec GraphQL: Renaming Types/Inputs (#5883)
* 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
2019-08-15 14:23:41 -07:00
Antoine Cormouls
4bffdce047 GraphQL: Inline Fragment on Array Fields (#5908)
* Inline Fragment Spec

* Inline Fragment on Arrays

* Fix Test

* Only select the root field

* Requested Changes

* Lazy Loaded ArrayResult
2019-08-14 12:25:28 -07:00
greenkeeper[bot]
4c1be61bed Update mongodb to the latest version 🚀 (#5914)
* 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
2019-08-14 01:25:49 +00:00
Antoine Cormouls
9031961e86 Return specific Type on specific Mutation (#5893)
* Return specific Type on specific Mutation

* Add Optimization on Mutation

* Optimize SignUp
2019-08-12 01:38:59 -07:00
Douglas Muraoka
f81da11b84 fix(GraphQL): Remove "password" output field from _User class (#5889) 2019-08-06 17:21:33 -07:00
Douglas Muraoka
ef14ca530d GraphQL Object constraints (#5715)
* 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
2019-08-02 12:18:07 -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
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