Skip to content

docs: add generated graphql api reference - #3745

Merged
crjm merged 22 commits into
dagger:mainfrom
crjm:graphql-api-docs
Nov 30, 2022
Merged

crjm merged 22 commits into
dagger:mainfrom
crjm:graphql-api-docs

Conversation

@crjm

@crjm crjm commented Nov 9, 2022 •

Copy link
Copy Markdown
Contributor

This will add a GraphQL API documentation generated with spectaql based on an introspection query or local schema files.

TODO

  • Add README
  • Change generation source from introspection query to local graphql files.
  • Allow insertion of examples for each query and types.
  • CI: trigger doc generation on core schema changes.
  • Apply custom styles based on branding: font, buttons, code snippets.
  • Decide in which URL this doc will live
  • Decide how should we integrate it with website, playground
  • Create an API doc introduction with markdown
  • Docs integration: add sidebar item in docs, etc
  • Remove unnecessary generated examples, variables, in queries
  • Decouple API Playground URL from example file

Closes #3048

Signed-off-by: Julián Cruciani [email protected]

@crjm crjm added area/documentation Improvements or additions to documentation area/graphql labels Nov 9, 2022
@crjm crjm added this to the Engine GraphQL release milestone Nov 9, 2022
@crjm
crjm requested a review from marcosnils November 9, 2022 15:56
@crjm crjm self-assigned this Nov 9, 2022
@crjm

crjm commented Nov 14, 2022 •

Copy link
Copy Markdown
Contributor Author

Iterating on the design with @Camille-Elairin

@mircubed

Copy link
Copy Markdown
Contributor

@crjm please let @shykes know how to see a preview, so he can provide feedback

@jpadams

jpadams commented Nov 14, 2022

Copy link
Copy Markdown
Contributor

@crjm myself and @kpenfound will push to this PR with snippets

@crjm

crjm commented Nov 14, 2022 •

Copy link
Copy Markdown
Contributor Author

Here is the link with the current state of the reference.
https://deploy-preview-3745--devel-docs-dagger-io.netlify.app/api/reference
@mircubed @shykes

@crjm

crjm commented Nov 15, 2022

Copy link
Copy Markdown
Contributor Author

Docs integration is being implemented in #3780

@mircubed

Copy link
Copy Markdown
Contributor

feedback from 11/18 call -

  • The separate website is fine for launch
  • remove full query
  • add object results with link to result type
  • put the link for the field. Right now, the link is in the example. So, please remove it from example because it is not going to map cleanly.
  • In the description, add the link to the reference type for that query

cc @shykes @samalba @crjm @marcosnils

@crjm

crjm commented Nov 22, 2022

Copy link
Copy Markdown
Contributor Author

Update: pushed a few changes. Still have to decouple API Playground link from example file.
Quick question: do we want to remove the auto-generated examples for the Types too?

image

cc @shykes @samalba @marcosnils

Comment thread website/package.json Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this, it seems that the graphql docs are regenerated every time you run npm start or npm build. It's possible that, when testing unrelated changes with npm start, the git diff would include changes arising from this graphql doc regeneration, which a developer would need to manually unstage before committing. Is there any way to avoid this?

I had a similar issue for the Node.JS docs which are also auto-generated and in that case, I added the auto-generated docs to the .gitignore file. It is not a perfect solution though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, you are right, it's not necessary to commit build artifacts, so we should put the static/graphql folder in .gitignore.
Polluting both the start and build commands was a concern I had when I implemented it because of the reason you mention.
The other alternative would be to modify the Netlify build command in netlify.toml so the docs are only generated at build time in Netlify, and if we need to test them locally, just run graphql-docs and docusaurus run/build separately.

@vikram-dagger vikram-dagger left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the inline comment, I'm not sure if the auto-generated static assets (images/JS/CSS) in static/graphql should be committed to the repo, as they are already included in docs-graphql/public.

@crjm

crjm commented Nov 23, 2022

Copy link
Copy Markdown
Contributor Author

Similar to the inline comment, I'm not sure if the auto-generated static assets (images/JS/CSS) in static/graphql should be committed to the repo, as they are already included in docs-graphql/public.

Nice catch, you reminded me to delete the docs-graphql/public folder, because it's the old output path. The output of the generated docs must live in static/graphql so that Docusaurus includes it in the build.

@crjm

crjm commented Nov 23, 2022 •

Copy link
Copy Markdown
Contributor Author

I'm working on these changes @vikram-dagger

@marcosnils

Copy link
Copy Markdown
Contributor

Quick question: do we want to remove the auto-generated examples for the Types too?

Yes, let's remove it.

Julián Cruciani added 12 commits November 25, 2022 12:23
Signed-off-by: Julián Cruciani <[email protected]>
Signed-off-by: Julián Cruciani <[email protected]>
Signed-off-by: Julián Cruciani <[email protected]>
Signed-off-by: Julián Cruciani <[email protected]>
Signed-off-by: Julián Cruciani <[email protected]>
Signed-off-by: Julián Cruciani <[email protected]>
Signed-off-by: Julián Cruciani <[email protected]>
Signed-off-by: Julián Cruciani <[email protected]>
Signed-off-by: Julián Cruciani <[email protected]>
Julián Cruciani added 5 commits November 25, 2022 12:27
Signed-off-by: Julián Cruciani <[email protected]>
Signed-off-by: Julián Cruciani <[email protected]>
Signed-off-by: Jeremy Adams <[email protected]>
@jpadams

jpadams commented Nov 26, 2022

Copy link
Copy Markdown
Contributor

@crjm can the code box be more flexible in size? With certain queries or certain zoom levels, content can get cut off

image

image

Julián Cruciani added 2 commits November 28, 2022 11:44
@crjm

crjm commented Nov 28, 2022 •

Copy link
Copy Markdown
Contributor Author

@crjm can the code box be more flexible in size? With certain queries or certain zoom levels, content can get cut off

Done!

jpadams and others added 2 commits November 29, 2022 07:28
Signed-off-by: Julián Cruciani <[email protected]>
@crjm
crjm merged commit ff97d84 into dagger:main Nov 30, 2022
@jpadams

jpadams commented Dec 11, 2022

Copy link
Copy Markdown
Contributor

fixes #3824

@jpadams

jpadams commented Dec 13, 2022

Copy link
Copy Markdown
Contributor

Netlify build mentioning socket
image

@crjm

crjm commented Dec 13, 2022 •

Copy link
Copy Markdown
Contributor Author

Netlify build mentioning socket

Yep, we talked with @vikram-dagger about this. Each time an example is missing, it will print that error to the console, warning about the example, but it will continue building anyway.
We thought that as it's a new query type, the most suitable contributor would be either @sipsma or @vito as they should have all the context.
This is the PR that introduced socket.
Related issue #4174

@marcosnils

Copy link
Copy Markdown
Contributor

it will print that error to the console, warning about the example, but it will continue building anyway.

that's nice. Should we make it fail instead? It'd be nice that if a new query type is added, CI automatically fails if no API reference examples have been added or if an intended action is taken to avoid having examples for that specific query.

@crjm

crjm commented Dec 13, 2022 •

Copy link
Copy Markdown
Contributor Author

that's nice. Should we make it fail instead? It'd be nice that if a new query type is added, CI automatically fails if no API reference examples have been added or if an intended action is taken to avoid having examples for that specific query.

We can, yes. Right now we are just printing the error instead of stopping the execution.

EDIT: I read "can" instead of "should", sorry.
IMO it makes sense, but I would leave this decision to the core team as they are going to change the schema files and maybe don't want to be bothered with an example if they need to ship quickly.
When there's a missing example, it looks like this. There's an empty "Example" title.

@vito

vito commented Dec 13, 2022

Copy link
Copy Markdown
Contributor

I'm onboard with a failing check for this. Writing an example shouldn't take that long. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Docs] Schema-based Reference Generation

6 participants