Summary of May 30th to June 1st

Laurent Wouters lwouters at cenotelie.fr
Fri Jun 1 18:29:16 CEST 2018


Dear all,

This is a quick report of the work going on this week (on my end) on CubicWeb. Still on the topic of GraphQL, I have been able to implement mutation queries, i.e. adding, removing and modifying objects. Due to the way GraphQL works I had to make some
choices as to what mutation queries would look like in CubicWeb. On the one hand, mutation queries in GraphQL are closer to stored procedures in spirit (i.e. business specific) than to a general-purpose language such as SQL or RQL on this aspect. On the
other hand, the aim was to provide a consistent implementation of GraphQL in CubicWeb regardless of the used YAMS schema. In the end, I opted for a simple approach as follow :

Reading queries makes entities unsurprisingly accessible through things like : Personne { firstname, surname }, etc.

The creation of new entities is written as : createPersonne(firstname: "john", surname: "doe").

The deletion of entities is expressed in a boringly similar fashion as : deletePersonne(firstname: "john"), which would delete any Personne entity with the matching attribute.

Finally, updating entities is written as : updatePersonne(old: {firstname: "john"}, new: {firstname: "jane"})

It is important to realize that all these expressions relies on a typed GraphQL data model for queries that is generated from the current YAMS schema at runtime. In addition, the resolution of all mutation queries is realized through the generation of a
nicely corresponding RQL statement.

The code for this change is accessible at https://bitbucket.org/laurentw/logilab-cubicweb/commits/39ecad7cd5cdc833751d96edac07f9534c6a960a

You can find examples of real queries in the tests at https://bitbucket.org/laurentw/logilab-cubicweb/src/39ecad7cd5cdc833751d96edac07f9534c6a960a/cubicweb/server/test/unittest_graphql.py?fileviewer=file-view-default

I will push this change for review on this list once it is ready with additional tests, probably at the beginning of next week.

Cheers,

Laurent


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: OpenPGP digital signature
URL: <http://lists.cubicweb.org/pipermail/cubicweb-devel/attachments/20180601/3ca6ec55/attachment.sig>


More information about the cubicweb-devel mailing list