You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All 3 tools had difficulty generating API docs from our GQL schema files, due to numerous linter errors (see #3136). However as they all support introspection, I was able to auto-generate API docs from the cloak dev server itself.
The first two tools generate markdown and a sidebar, so can be immediately integrated with Docusaurus. SpectaQL generates HTML, so can be integrated only as a separate set of static pages. This also means it does not automatically inherit the current doc site's CSS, it needs to be manually set up to match the existing doc site's layout and CSS. Alternatively, we would need to run a second process to convert the HTML to markdown, after which the files can be treated like other Docusaurus content.
The first tool produces output in a hardcoded output directory, so the files need to be manually moved to the correct location. The other two tools don't have this issue.
SpectaQL docs, by virtue of being separate HTML pages, always open in a new tab as this is the Docusaurus default behaviour.
All three tools generate unified reference docs ie. core and extension APIs are merged in the output docs. This is because they use the GraphQL introspection API. If we wish to show our core and extension APIs separately in the navigation tree (which IMO is preferable), we would need to instead use the schema files as source, writing a script that runs the docs generator once for each schema and then move each set of generated files to the correct location in the Docusaurus filesystem.
Thanks for taking care of this @vikram-dagger, both for the work and the summary of each alternative. 🙏
I really did not have enough time to dig into this, but I agree the second option is the best one based on your insights.
I'm not very sure how to correct this since the output is based on the schema obtained from introspection - for auto-generated docs, we would probably need to find a way to represent this in the schema itself so it gets reflected in the output docs. Maybe add an example in the schema? Separately, I have checked and it's possible to exclude some sections (eg. queries) from being generated.
The upside of using the Docusaurus plugins is that we get the same style and website for both the API and the SDK docs. However, both plugins are short on content quality, as they only reproduce the schema in markdown files.
spectaql on the other hand, doesn't have Docusaurus as a limitation (it's not forced to output .md files). This makes spectaql a better choice for content quality, but at the same time it breaks with having the API docs and SDK docs in the same docs site.
From a user standpoint, rich and ready-to-use content is more valuable than CSS styling and one docs site to tackle all documentation, so my thinking is: let's dig more into spectaql which allows more fine-grained customization on the output and then we'll see how to best integrate it into docs.dagger.io. I think that, for now, having a title with the same hierarchy as the rest of the SDKs in the docs and making it a link to api.docs.dagger.io, is the best choice.
This is still open for discussion though. Will come back with updates on the different possibilities around spectaql.
This is the reference in it's current state
In summary, we have an API reference generated from the schema files that live in core/schema using spectaql instead of Docusaurus. This reference has examples for each query and, possibly, a link to an execution of that query in the Playground. (design still needs refinement)
The main reason we didn't choose Docusaurus is basically time. The Docusaurus plugins that generate schema-based documentation did not allow enough customization (cannot provide examples, etc), while spectaql did.
However, there's a better approach, but more time-consuming: a custom Docusaurus plugin (injects data into Docusaurus). This way the API reference would live inside the Docusaurus SPA and share styles with the documentation. If the GraphQL release date gets pushed, I might have enough time to make it. It's a question of tradeoffs.
Activity
vikram-dagger commentedon Sep 19, 2022
I investigated the following options:
All 3 tools had difficulty generating API docs from our GQL schema files, due to numerous linter errors (see #3136). However as they all support introspection, I was able to auto-generate API docs from the
cloak devserver itself.See examples of the auto-generated API output at https://vikram-dagger.github.io/.
Summary of results:
Recommendation:
Simply because it seems to require the least work to connect with the existing Docusaurus site and the output seems reasonable, I suggest using the second option https://www.npmjs.com/package/@edno/docusaurus2-graphql-doc-generator. However, before deciding, I recommend looking at the navigation structure, layout and content of the generated API docs for all three examples to see if one of them is significantly better than the others.
Next steps:
crjm commentedon Sep 28, 2022
Thanks for taking care of this @vikram-dagger, both for the work and the summary of each alternative. 🙏
I really did not have enough time to dig into this, but I agree the second option is the best one based on your insights.
vikram-dagger commentedon Sep 28, 2022
First cut of auto-generated docs included in #3160
jpadams commentedon Sep 28, 2022
Nice work! 🎉
Going through it, the "queries" are not really useful it seems:
since a working
{ alpine }query needs more.We list that in the Objects section, but it's not a proper query either...it's showing the schema:
Users need this query to do useful work:
vikram-dagger commentedon Oct 1, 2022
I'm not very sure how to correct this since the output is based on the schema obtained from introspection - for auto-generated docs, we would probably need to find a way to represent this in the schema itself so it gets reflected in the output docs. Maybe add an example in the schema? Separately, I have checked and it's possible to exclude some sections (eg. queries) from being generated.
crjm commentedon Oct 3, 2022
I think comments are used to generate text for GraphiQL docs, but I don't think they are the most suitable solution in this case.
mircubed commentedon Nov 3, 2022
@vikram-dagger can I close this since we are using #3668 to make a decision?
vikram-dagger commentedon Nov 4, 2022
I think we should leave it open as this may come up again for the GraphQL launch
crjm commentedon Nov 8, 2022
Reviving this one, currently working on it.
crjm commentedon Nov 8, 2022
The upside of using the Docusaurus plugins is that we get the same style and website for both the API and the SDK docs. However, both plugins are short on content quality, as they only reproduce the schema in markdown files.
spectaqlon the other hand, doesn't have Docusaurus as a limitation (it's not forced to output.mdfiles). This makesspectaqla better choice for content quality, but at the same time it breaks with having the API docs and SDK docs in the same docs site.From a user standpoint, rich and ready-to-use content is more valuable than CSS styling and one docs site to tackle all documentation, so my thinking is: let's dig more into
spectaqlwhich allows more fine-grained customization on the output and then we'll see how to best integrate it intodocs.dagger.io. I think that, for now, having a title with the same hierarchy as the rest of the SDKs in the docs and making it a link toapi.docs.dagger.io, is the best choice.This is still open for discussion though. Will come back with updates on the different possibilities around
spectaql.marcosnils commentedon Nov 9, 2022
spectaqlar (cuack 🦆) analysis Juli. Looking forward to this 👐
mircubed commentedon Nov 14, 2022
@crjm can you provide a summary here, so @shykes knows what to review/approve? I want to make sure that we don't get stuck on last minute feedback.
crjm commentedon Nov 14, 2022
This is the reference in it's current state
In summary, we have an API reference generated from the schema files that live in
core/schemausingspectaqlinstead of Docusaurus. This reference has examples for each query and, possibly, a link to an execution of that query in the Playground. (design still needs refinement)The main reason we didn't choose Docusaurus is basically time. The Docusaurus plugins that generate schema-based documentation did not allow enough customization (cannot provide examples, etc), while spectaql did.
However, there's a better approach, but more time-consuming: a custom Docusaurus plugin (injects data into Docusaurus). This way the API reference would live inside the Docusaurus SPA and share styles with the documentation. If the GraphQL release date gets pushed, I might have enough time to make it. It's a question of tradeoffs.