{"id":13907345,"url":"https://github.com/postmanlabs/graphql-to-postman","last_synced_at":"2025-04-12T21:34:34.933Z","repository":{"id":37885534,"uuid":"226858518","full_name":"postmanlabs/graphql-to-postman","owner":"postmanlabs","description":" Plugin for converting GraphQL to the Postman Collection (v2) format","archived":false,"fork":false,"pushed_at":"2025-03-07T13:42:18.000Z","size":213,"stargazers_count":37,"open_issues_count":31,"forks_count":16,"subscribers_count":8,"default_branch":"develop","last_synced_at":"2025-03-28T02:14:30.085Z","etag":null,"topics":["graphql","postman","postman-collection"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postmanlabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-12-09T11:47:31.000Z","updated_at":"2025-03-20T07:21:08.000Z","dependencies_parsed_at":"2024-04-04T15:27:21.567Z","dependency_job_id":"517bb1de-f34c-4381-8f2d-c62ac0c1bcfc","html_url":"https://github.com/postmanlabs/graphql-to-postman","commit_stats":{"total_commits":78,"total_committers":8,"mean_commits":9.75,"dds":"0.33333333333333337","last_synced_commit":"f93a04ecf7e1cb2c5044f4dd9a1b4ccbaf5c180c"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Fgraphql-to-postman","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Fgraphql-to-postman/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Fgraphql-to-postman/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postmanlabs%2Fgraphql-to-postman/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postmanlabs","download_url":"https://codeload.github.com/postmanlabs/graphql-to-postman/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247112741,"owners_count":20885606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","postman","postman-collection"],"created_at":"2024-08-06T23:01:53.921Z","updated_at":"2025-04-04T03:03:21.417Z","avatar_url":"https://github.com/postmanlabs.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"\u003cimg src=\"https://voyager.postman.com/logo/postman-logo-orange.svg\" width=\"320\" alt=\"The Postman Logo\"\u003e\n\n*Supercharge your API workflow.*\n*Modern software is built on APIs. Postman helps you develop APIs faster.*\n\n# GraphQL to Postman Collection\n\n![Build Status](https://github.com/postmanlabs/graphql-to-postman/actions/workflows/test.yml/badge.svg)\n\n\u003ca href=\"https://www.npmjs.com/package/graphql-to-postman\" alt=\"Latest Stable Version\"\u003e![npm](https://img.shields.io/npm/v/graphql-to-postman.svg)\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/graphql-to-postman\" alt=\"Total Downloads\"\u003e![npm](https://img.shields.io/npm/dw/graphql-to-postman.svg)\u003c/a\u003e\n\n#### Contents\n\n1. [Getting Started](#getting-started)\n2. [Command Line Interface](#command-line-interface)\n    1. [Options](#options)\n    2. [Usage](#usage)\n3. [Using the converter as a NodeJS module](#using-the-converter-as-a-nodejs-module)\n    1. [Convert Function](#convert)\n    2. [Options](#options)\n    3. [ConversionResult](#conversionresult)\n    4. [Sample usage](#sample-usage)\n    5. [Validate function](#validate-function)\n4. [Conversion Schema](#conversion-schema)\n\n---\n\n---\n\n\n## 💭 Getting Started\n\nTo use the converter as a Node module, you need to have a copy of the NodeJS runtime. The easiest way to do this is through npm. If you have NodeJS installed you have npm installed as well.\n\n```terminal\n$ npm install graphql-to-postman\n```\n\nIf you want to use the converter in the CLI, install it globally with NPM:\n\n```terminal\n$ npm i -g graphql-to-postman\n```\n\n\n## 📖 Command Line Interface\n\nThe converter can be used as a CLI tool as well. The following [command line options](#options) are available.\n\n`gql2postman [options]`\n\n### Options\n\n- `-s \u003csource\u003e`, `--spec \u003csource\u003e`\n  Used to specify the GraphQL specification (file path) which is to be converted\n\n- `-o \u003cdestination\u003e`, `--output \u003cdestination\u003e`\n  Used to specify the destination file in which the collection is to be written\n\n- `-p`, `--pretty`\n  Used to pretty print the collection object while writing to a file\n\n- `-i`, `--interface-version`\n  Specifies the interface version of the converter to be used. Value can be 'v2' or 'v1'. Default is 'v2'.\n\n- `-O`, `--options`\n  Used to supply options to the converter, for complete options details see [here](/OPTIONS.md)\n\n- `-c`, `--options-config`\n  Used to supply options to the converter through config file, for complete options details see [here](/OPTIONS.md)\n\n- `-t`, `--test`\n  Used to test the collection with an in-built sample specification\n\n- `-v`, `--version`\n  Specifies the version of the converter\n\n- `-h`, `--help`\n  Specifies all the options along with a few usage examples on the terminal\n\n\n###  Usage\n\n- Takes a specification (spec.yaml) as an input and writes to a file (collection.json) with pretty printing and using provided options\n```terminal\n$ gql2postman -s spec.yaml -o collection.json -p -O depth=3,includeDeprecatedFields=true\n```\n\n- Takes a specification (spec.yaml) as an input and writes to a file (collection.json) with pretty printing and using provided options via config file\n```terminal\n$ gql2postman -s spec.yaml -o collection.json -p  -c ./examples/cli-options-config.json\n```\n\n- Takes a specification (spec.yaml) as an input and writes to a file (collection.json) with pretty printing and using provided options with larger depth limit\n  to make sure more detailed and nested data is generated.\n```terminal\n$ gql2postman -s spec.yaml -o collection.json -p -O depth=7,includeDeprecatedFields=true,optimizeConversion=false\n```\n\n- Testing the converter\n```terminal\n$ gql2postman --test\n```\n\n\n## 🛠 Using the converter as a NodeJS module\n\nIn order to use the convert in your node application, you need to import the package using `require`.\n\n```javascript\nvar Converter = require('graphql-to-postman')\n```\n\nThe converter provides the following functions:\n\n### Convert\n\nThe convert function takes in your GraphQL schema or SDL and converts it to a Postman collection.\n\nSignature: `convert (data, options, callback);`\n\n**data:**\n\n```javascript\n{ type: 'file', data: 'filepath' }\nOR\n{ type: 'string', data: '\u003centire GraphQL string - schema or SDL\u003e' }\n```\n\n**options:**\n```javascript\n{\n  depth: 4,\n  includeDeprecatedFields: false,\n  optimizeConversion: false\n}\n/*\nAll three properties are optional. Check the options section below for possible values for each option.\n*/\n```\n\n**callback:**\n```javascript\nfunction (err, result) {\n  /*\n  result = {\n    result: true,\n    output: [\n      {\n        type: 'collection',\n        data: {..collection object..}\n      }\n    ]\n  }\n  */\n}\n```\n\n### Options\n\n- `depth` - The number of levels of information that should be returned. (A depth level of “1” returns that object and\n    its properties. A depth of “2” will return all the nodes connected to the level 1 node, etc.)\n\n- `includeDeprecatedFields` - Generated queries will include deprecated fields or not.\n\n- `optimizeConversion` - Optimizes conversion for schemas with complex and nested input objects by reducing the depth to\n    which input objects are resolved in GraphQL variables.\n\n### ConversionResult\n\n- `result` - Flag responsible for providing a status whether the conversion was successful or not.\n\n- `reason` - Provides the reason for an unsuccessful conversion, defined only if result if `false`.\n\n- `output` - Contains an array of Postman objects, each one with a `type` and `data`. The only type currently supported is `collection`.\n\n\n\n### Sample Usage\n```javascript\nconst fs = require('fs'),\n  Converter = require('graphql-to-postman'),\n  gqlData = fs.readFileSync('sample-spec.yaml', {encoding: 'UTF8'});\n\nConverter.convert({ type: 'string', data: gqlData },\n  {}, (err, conversionResult) =\u003e {\n    if (!conversionResult.result) {\n      console.log('Could not convert', conversionResult.reason);\n    }\n    else {\n      console.log('The collection object is: ', conversionResult.output[0].data);\n    }\n  }\n);\n```\n\n### Validate Function\n\nThe validate function is meant to ensure that the data that is being passed to the [convert function](#convert-function) is a valid JSON object or a valid (YAML/JSON) string.\n\nThe validate function is synchronous and returns a status object which conforms to the following schema\n\n#### Validation object schema\n\n```javascript\n{\n  type: 'object',\n  properties: {\n    result: { type: 'boolean'},\n    reason: { type: 'string' }\n  },\n  required: ['result']\n}\n```\n\n##### Validation object explanation\n- `result` - true if the data is valid GraphQL and can be passed to the convert function\n\n- `reason` - Provides a reason for an unsuccessful validation of the specification\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostmanlabs%2Fgraphql-to-postman","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostmanlabs%2Fgraphql-to-postman","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostmanlabs%2Fgraphql-to-postman/lists"}