eros_gql
v1.2.8
Published
Documentation generator from a graphql file
Readme
Eros_gql
This project generate a doc for a GraphQL API created with Nest.js.
Do not support schema with directives, subscriptions, comments and union type for the moment.
Use
- node
^v16.13.2 - randexp
How to
Install the package.
npm i eros_gqlIn your package.json script add a script "eros": "eros_gql".
Add a conf file named eros.conf.json (example below).
Running the script will generate a file eros.data.json that save all generated value, you can edit the file to change the value generated in your documentation.
Run your script.
npm run erosExample eros.conf.json:
{
"input": "./gqlschema.gql",
"output": {
"path": "./genDoc/",
"dirName": "api"
},
"maxDepth": 2,
"app": {
"title": "app Title",
"description": "app description"
},
"tree": {
"user": [
{
"requestName": "users",
"errors": [
{
"name": "NOT_FOUND",
"reason": "User not found"
}
]
},
{
"requestName": "createUser"
}
],
"post": [
{
"requestName": "posts"
},
{
"requestName": "createPost"
}
]
},
"scalars":[
{
"name": "TextField",
"regex": "^[a-zA-Z0-9-/'.@ çàèéùâêîôûäëïöü]*$"
},
{
"name": "CustomID",
"regex": "^[a-zA-Z0-9-/'.@ çàèéùâêîôûäëïöü]*$"
}
]
}Conf documentation
1. Script conf
inputis the path to your graphl schema.outputhave two properties.paththe path where the documentation will be generated.dirNamethe name of the directory that will contain all the genrated files.
maxDepthused to avoid infinite loop.
2. Defining your documentation:
app
Your app information.
titleis the app's title.desciptionis the app's description ,optionable.
tree
Your documentation structure.
Each property is a folder with a list of request's name from your gql schema.
Here user will be a folder containing the request users.
Each request need a requestName property and can have a list of errors.
Request specified in a folder will be listed under the folder name in the table of content.
scalars
Specify your custom scalars.
An array of object with properties name and regex.
Only support regex for now.
The specified scalars will appear in the table of content.
