Problem/Motivation
The primary impetus for using JSON API w/ Drupal is a module which you can simply enable and become productive with immediately. Part of what makes a module immediately useful is clear documentation which provides simple and usable examples as well as easy-to-understand instructions to accomplish the most common operations.
Documentation for the module is clearly needed, see #2798279: [TASK] Create a JSON API extension for filtering for example.
We've reached a point of enough stability that investing in excellent documentation is a worthwhile effort. Documentation is likely to remain valid even if we refactor internally.
I would like to see us document all the information that lives in our current demo videos. While very useful, they are not searchable and it is difficult to link to specific bits of information.
We also need to provide very solid documentation around the filtering syntax we've come up up with for this module. Once we've come up with really solid documentation and worked out any remaining bugs in this filter syntax, it could potentially become a well-supported JSON API extension.
Readers of this issue are encouraged to add new requests for documentation in the comments below.
Proposed resolution
We should create a new book on drupal.org for the module and begin documenting how to work with the module in practice. I would like to also reach out to any front end developers for help with this documentation. Some of this documentation is probably good for REST in general and we could contribute this to the core docs and link to it from our own pages.
Remaining tasks
We need to document:
- We should broadly include a page which maps Drupalism like entity types and bundles to our types and entity references to relationships. This should also include JSON API concepts like links, relationships, include, and field parameters and how they should be used in practice.
- Authentication strategies
- CSRF tokens
- GET - Individual
- GET - Collection (to include sub pages for: sort, page and filter syntax)
- POST (should include examples of how to specify bundle types and how creating resources with client-side UUIDs)
- PATCH (can largely duplicate POST, but we should provide direct links for each topic, not "see POST documentation")
- DELETE
Comment | File | Size | Author |
---|---|---|---|
#19 | docs-patch.patch | 1.08 KB | JanLaureys |
#6 | 2016-09-14-filtering.txt | 5.51 KB | JanLaureys |
#4 | 2016-09-14-filtering.pdf | 42.84 KB | JanLaureys |
Comments
Comment #2
e0ipsoThis playlist can serve as documentation as well. We should probably have a textified version of them https://www.youtube.com/playlist?list=PLZOQ_ZMpYrZsyO-3IstImK1okrpfAjuMZ.
Comment #3
JanLaureys CreditAttribution: JanLaureys commentedI'm currently working on the page for the filtering syntax.
Comment #4
JanLaureys CreditAttribution: JanLaureys commentedFirst draft for the filtering page. I'm writing it in markdown right now, but if the book is set up I can insert it directly into drupal.org ?
Comment #5
e0ipso@JanLaureys if you share the markdown document it would be easier for someone to review your docs :-)
Thanks for your work!!
Comment #6
JanLaureys CreditAttribution: JanLaureys commented@e0ipso. Yeah, I couldn't upload .md files, but I had a sudden realisation that I can just make it into a .txt file.
Comment #7
gabesulliceI've added the first parent page for the module here:
https://www.drupal.org/node/2803093
Comment #8
e0ipso@JanLaureys can you add the filtering documentation in a child page of the "JSON API" that @gabesullice just created? We can probably iterate on that there.
Comment #9
gabesullice@JanLaureys please add your documentation to this page: https://www.drupal.org/node/2803141
Comment #10
dagmarI added the documentation to change the api prefix and the use of IDs instead of UUIDs https://www.drupal.org/node/2804085
Comment #11
e0ipsoThanks everyone for your efforts. We have started on a great path!
Comment #12
JanLaureys CreditAttribution: JanLaureys commentedAdded my docs to the filtering page. I'll try reformatting the titles etc. soon. I'll also add some examples for sorting and pagination, and if someone wants to rewrite some of my convoluted sentences, feel free :).
Comment #13
Sutharsan CreditAttribution: Sutharsan commentedFor better discoverability of the documentation page I suggest to list the documentation page from the project's page. Projects only can have one documentation link, but we may use the 'Demo' link and/or cross-link from d.o page to video.
Comment #14
e0ipsoComment #15
e0ipsoThat was a great suggestion @Sutharsan. That should be linked now.
Comment #16
e0ipsoHuge thanks to @Sutharsan for creating the documentation in https://www.drupal.org/node/2806567.
Comment #17
e0ipsoIf you're creating documentation, writing blog posts, recording videos, etc. Please leave a trace here and we'll find a way to highlight all your contributions!
Comment #18
e0ipsoWe probably need some documentation on how to disable specific resources: see #2781459: [FEATURE] Allow disabling resources.
Comment #19
JanLaureys CreditAttribution: JanLaureys commentedI updated the link in the _help hook :)
Comment #20
clemens.tolboomAs the project page is pimped up and references to both https://www.drupal.org/docs/8/modules/json-api/json-api and the Youtube video is this task still open or can it be closed?
#18 is now for https://www.drupal.org/project/jsonapi_extras I guess which is mentioned on the project page.
#19
@JanLaureys you better place your patch in a separate issue then with needs review I guess.
Comment #21
mattferderer CreditAttribution: mattferderer commentedI found this module the other day while working on a prototype. As someone completely new to this project & decoupled Drupal sites, here's my 2 cents in case it helps your documentation with other people who are very new. Overall I thought the YouTube videos & documentation are already better than 99% of other Drupal modules. It would be nice to see some more concrete examples though. As a new person, here's what the path I took.
I use the Paragraphs module & it seems this is a very common approach to decoupled sites. It seems silly now but it took me a while to realize that including content from the paragraphs was as easy as querying the node I wanted & adding ?include={name_of_field_in_node_that_uses_paragraphs}
Querying individual paragraphs also took a little bit of time. I know realize I can query a paragraph by using /jsonapi/paragraph/paragraph_type/id
Based on my knowledge of how to query paragraphs, I tried to apply this to Drupal menus. Unfortunately the same logic didn't work to query a menu. Querying menus would be great to see added to the documentation. After that, I feel like I could make a decoupled website fairly quick with just the JSON API.
Just another kudos, as I've tried the other API modules Drupal offers in the core. This one was a lot simpler & better than all of them. It's saving me from creating a lot of views & making a lot of XHR requests from JavaScript.
Comment #22
clemens.tolboom@mattferderer thank for you feedback.
Testing with your mentioned
I checked the documentation page https://www.drupal.org/node/2806623 which does not mentions config entities and how to use them. So I added an example to it. Please review.
If you want to follow the CRUD on Config entities #2300677: JSON:API POST/PATCH support for fully validatable config entities is a good starting point.
Comment #23
mattferderer CreditAttribution: mattferderer commentedThanks @clemens.tolboom. The extra documentation is helpful. My guess is most beginners are just looking to read data so that works perfectly!
Just out of curiosity, when you query the menu do you get any of the menu links back? I just get some basic info about the menu but not the structure. I apologize if this should be a separate issue.
Comment #24
e0ipso@mattferderer the menu links are not loaded as part of nodes. That is a known (debatable) Drupal behavior. Is that what you are experiencing?
Comment #25
mattferderer CreditAttribution: mattferderer commentedYep, that is @e0ipso. After some research I came to that conclusion as well. Looks like some other modules have been created to help with that though. I'm using the Rest menu items module & they just added the UUID field in their response. Using that should integrate well with the JSON API to overcome this.
Comment #26
clemens.tolboomPlease vote on #2892600: Add module category 'Decoupled', 'API First', 'Rest' or 'headless'.
@mattferderer full links help more :-p
- https://www.drupal.org/project/rest_menu_items
- https://www.drupal.org/project/rest_menu_tree
Comment #27
clemens.tolboom@e0ipso the patch from #19 didn't popped up I guess? It is a useful change right?
We should close this issue if possible.
Comment #28
clemens.tolboomHmmm .... the documentation page https://www.drupal.org/docs/8/modules/json-api/json-api states
What should we do? Close this issue or keep it open indefinitely?
Comment #29
Wim LeersSeems like https://www.drupal.org/docs/8/modules/json-api/json-api is pretty well fleshed out, and has been for many months. No need to keep this issue open.
EDIT: and most importantly, it's linked from https://www.drupal.org/project/jsonapi, so it's discoverable!