farmOS / farmOS.js

A JavaScript library for working with farmOS data structures and interacting with farmOS servers.
MIT License
17 stars 13 forks source link

Replace schema stubs #26

Closed jgaehring closed 3 years ago

jgaehring commented 3 years ago

Right now I'm using some stubs for traversing and generating defaults from JSON Schema, namely:

https://github.com/farmOS/farmOS.js/blob/5578f087ac3080fa86732cd1c930a6c81e294a42/src/utils/index.js#L6-L10

Obviously these need to be replaced, even if we can get by without them for the time being in Field Kit.

jgaehring commented 3 years ago

Just thinking about schema stuff again today, and looking at the JSON:API spec, I was reminded of this issue up on d.o, which I think will need to be revisited when replacing these stubs:

https://www.drupal.org/project/drupal/issues/3199974

As a contributor mentioned in the comments there, it seems like we can achieve a lot of what's needed via the JSON:API Extras module. But this will definitely require some broader discussion about what expectations we're setting with the API, so I'll need input/help from @mstenta, @paul121 and others to figure out how best to proceed.

Also, one small point I want to correct from my first follow-up comment there:

The meta object is a top-level property on the JSON:API document itself, alongside the data property. I was mistaken in thinking meta was part of the resource object.

Actually, meta objects can be members of both the top-level document and individual resource objects. So my original idea of moving such fields as drupal_internal__revision_id from the resource's attributes to meta would still work, at least in theory, without breaking compliance with JSON:API.

jgaehring commented 3 years ago

Resolved by 731f8a3.