Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow new fields to be added locally to schema (#1139)
* Correct P2P error message Spotted and quickly corrected. Has nothing to do with this PR though, but is small enough to include. * Remove field kind decimal It is not supported and does not work. Leaving it here will just confuse users, especially as they start to use the schema update system. * Remove field kind bytes It is not supported and does not work. Leaving it here will just confuse users, especially as they start to use the schema update system. * Remove field embedded object kinds They are not supported and does not work. Leaving it here will just confuse users, especially as they start to use the schema update system. * Add documentation to FieldDesc.Kind I'm not sure any more than this is really needed, especially given that we will largely be hiding this from users shortly after merge. * Assert for collection name uniquenss within SDL Previously this would partially succede - the gql types would be updated, but the saving of the collection descriptions would fail (as there is another uniqueness check there), leaving the database in an invalid state until restart. * Correctly query all existing collections Was incorrectly quering the version history, returning a collection per version, instead of just the current version. Went unnoticed as previously each collection could only have a single version. * Make collection persistance transactional Collection stuff needs to be protected by transactions. Partial success of either a create or a mutate cannot be permitted and the use of transactions protects against this. The transactions are also needed to protect against the use of stale data, by including the collection in the transaction used for P2P and query/planner stuff we should ensure that stuff is done against a single, complete version of the collection, and that it is not possible for the collection to mutate whilst something is using the collection. At the moment such concurrent use should now result in a transaction conflict error - this is not ideal and the logic here should probably grow to permit the queuing of such clashes (e.g. through use of a mutex) instead of making the users retry until it succedes - such a change will very likely need to be done within the scope declared by the transaction anyway, so I see no wasted code/time by the changes in this commit here - it is a start, and prevents odd/damaging stuff from happening. DB init was also covered almost as a side-affect, as the sequence needed protecting, and TBH it is probably a very good thing to protect against mutating the database state in the case of a failed init. * Make SetSchema (GQL) transactional Renames and changes AddSchema to SetSchema. SetSchema is now transactional, GQL type changes will now only be 'commited' on transaction commit, whilst allowing SetSchema to be called safely at any point during the lifetime of the transaction - allowing for the schema to be validated against GQL constraints before any changes have been persisted else where, and allowing those other changes to be executed/validated before any changes have been made to the GQL types. * Add support for adding fields to schema Please note that the client interfaces will be reworked in the near future so that the transaction related items clutter the primary interface less, and are more consistent. For now I have just followed the existing `Txn` suffix naming.
- Loading branch information