Usage
#
Installation- In an existing Docusaurus project, install the plugin:
- Add the plugin to your
docusaurus.config.js
file:
Run the command
npx docusaurus docs:generate:graphql
The command will have generated files that you can now add to your
sidebars.js
:
- You can now run
yarn start
to serve your documentation
#
Optionsid
#
This option is common to docusaurus plugins and can be used to differentiate multiple instance of the plugin. For example:
With the configuration above you would end up with two different commands:
docs:generate:graphql:first-api
docs:generate:graphql:second-api
schema
#
Can be a path, a glob or an URL used to load your GraphQL schema.
routeBasePath
#
Defaults: /docs/api/
This option can be used to customize the output folder and thus the GraphQL docs' path.
For example if you want the API docs to be served over /docs/api-reference/
instead of /docs/api/
, you can change this option to /docs/api-reference/
. Note that you can also have more levels to the path, e.g /docs/reference/api/
.
sidebar
#
This option can be used to specify sidebar metadata when using auto-generated sidebar.
The configuration above will create a _category_.json
file in the routeBasePath
looking like this :