Escape-Technologies / graphman

Quikly scaffold a postman collection for a GraphQL API. Compatible with Postman & Insomnia.
MIT License
240 stars 12 forks source link

Include a documentation in the generated collection #31

Closed Gbahdeyboh closed 1 year ago

Gbahdeyboh commented 1 year ago

GraphQL provides us with the option to include descriptions in our schema. Descriptions can be field or list descriptions. Tools like GraphiQL use these descriptions in the generated documentation for any GraphQL schema.

These same behaviors can be replicated in collections as well. It helps the consumer of that collection with additional with some additional context.

nohehf commented 1 year ago

For now, the descriptions are included in the queries as comments, but I agree that it would be nice to put it in this more appropriate space.

nohehf commented 1 year ago

Hey @Gbahdeyboh I got an issue on this one. In the postman collection spec the description is as:

"item": {
 "...":"...",
 "description": "..."
}

However, when doing that no description is shown in postman, and if I manually add one and export the collection, I get the following scheme:

"item": {
 "...":"...",
 "request": {
    "...":"...",
    "description": "..."
  }
}

Complete context:

{
  "name":"character",
  "request":{
    "method":"POST",
    "header":[

    ],
    "body":{
      "mode":"graphql",
      "graphql":{
        "query":"query character($id: ID!) {\n  character(id: $id) {\n    __typename\n    id # The id of the character.\n    name # The name of the character.\n    status # The status of the character ('Alive', 'Dead' or 'unknown').\n    species # The species of the character.\n    type # The type or subspecies of the character.\n    gender # The gender of the character ('Female', 'Male', 'Genderless' or 'unknown').\n    # origin # The character's origin location\n    # location # The character's last known location\n    image # Link to the character's image. All images are 300x300px and most are medium shots or portraits since they are intended to be used as avatars.\n    # episode # Episodes in which this character appeared. # Type: NON_NULL\n    created # Time at which the character was created in the database.\n  }\n}",
        "variables":"{\n\t\"id\": \"0\"\n}"
      }
    },
    "url":{
      "raw":"https://rickandmortyapi.com/graphql",
      "protocol":"https",
      "host":[
        "rickandmortyapi",
        "com"
      ],
      "path":[
        "graphql"
      ]
    },
    "description":"exported description from postman"
  },
  "response":[

  ],
  "description":"description as described in the docs"
}
nohehf commented 1 year ago

Note: move the description to the request level