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
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gabesullice created an issue. See original summary.

e0ipso’s picture

This 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.

JanLaureys’s picture

I'm currently working on the page for the filtering syntax.

JanLaureys’s picture

FileSize
42.84 KB

First 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 ?

e0ipso’s picture

@JanLaureys if you share the markdown document it would be easier for someone to review your docs :-)

Thanks for your work!!

JanLaureys’s picture

FileSize
5.51 KB

@e0ipso. Yeah, I couldn't upload .md files, but I had a sudden realisation that I can just make it into a .txt file.

gabesullice’s picture

I've added the first parent page for the module here:
https://www.drupal.org/node/2803093

e0ipso’s picture

@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.

gabesullice’s picture

@JanLaureys please add your documentation to this page: https://www.drupal.org/node/2803141

dagmar’s picture

I added the documentation to change the api prefix and the use of IDs instead of UUIDs https://www.drupal.org/node/2804085

e0ipso’s picture

Thanks everyone for your efforts. We have started on a great path!

JanLaureys’s picture

Added 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 :).

Sutharsan’s picture

For 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.

e0ipso’s picture

Issue tags: +Dublin2016
e0ipso’s picture

That was a great suggestion @Sutharsan. That should be linked now.

e0ipso’s picture

Huge thanks to @Sutharsan for creating the documentation in https://www.drupal.org/node/2806567.

e0ipso’s picture

If 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!

e0ipso’s picture

We probably need some documentation on how to disable specific resources: see #2781459: [FEATURE] Allow disabling resources.

JanLaureys’s picture

FileSize
1.08 KB

I updated the link in the _help hook :)

clemens.tolboom’s picture

As 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.

mattferderer’s picture

I 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.

clemens.tolboom’s picture

@mattferderer thank for you feedback.

Testing with your mentioned

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.

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.

mattferderer’s picture

Thanks @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.

e0ipso’s picture

@mattferderer the menu links are not loaded as part of nodes. That is a known (debatable) Drupal behavior. Is that what you are experiencing?

mattferderer’s picture

Yep, 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.

clemens.tolboom’s picture

clemens.tolboom’s picture

@e0ipso the patch from #19 didn't popped up I guess? It is a useful change right?

We should close this issue if possible.

clemens.tolboom’s picture

Hmmm .... the documentation page https://www.drupal.org/docs/8/modules/json-api/json-api states

If you feel something should be included in this documentation, but do not have the know-how or expertise to add them yourself, development of this documentation is being tracked in this issue: #2798817: [TASK] Create documentation pages on drupal.org

What should we do? Close this issue or keep it open indefinitely?

Wim Leers’s picture

Status: Active » Fixed

Seems 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!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.