- Issue created by @timfletcher
Last time I checked, the Views Reference field isn’t output in JSONAPI when inspecting a node that features one.
This means that headless Drupal sites with frontends that depend on JSONAPI output for building components need a workaround to retrieve Views data separately.
In my case, I used the JSONAPI Views → module to expose the output of Views I needed. This works fine for accessing View data directly, provided you know the exact URL of the View including any arguments/filters.
This is where the editing experience falls over when using headless Drupal.
To view the Views Reference field output:
1. Add a Views Reference field to a Content Type.
2. Create a new piece of content and select a View to add.
3. Save the new content
4. Visit <mysite.com>/jsonapi
and select the endpoint link for that Content Type
5. Locate your saved node and inspect the Fields list output. The View Reference field should not appear.
I believe it would be much nicer UX if:
1. Editors chose their Views using Views Reference Field, then
2. The ID, display, args, limit, contextual filters etc of their selected View displays in the JSONAPI output for that node; and finally
3. If the JSONAPI Views module is installed, include a reference to that View endpoint URL under the node’s ‘relationship’ key in the JSONAPI output.
Decide on feasibility of this idea.
Active
2.0
Code