{"_id":"@testmail.app/graphql-request","_rev":"2-201e275c5b134a961f5bb45fa5a54ac2","name":"@testmail.app/graphql-request","dist-tags":{"latest":"1.8.4"},"versions":{"1.8.3":{"name":"@testmail.app/graphql-request","description":"Clone of graphql-request (minimal GraphQL client) with improvements like built-in retries","version":"1.8.3","main":"dist/src/index.js","typings":"./dist/src/index.d.ts","bundlesize":[{"path":"./dist/src/index.js","maxSize":"15 kB"}],"repository":{"type":"git","url":"git+https://github.com/testmail-app/graphql-request.git"},"keywords":["graphql","request","fetch","graphql-client","apollo"],"author":{"name":"Amit","email":"amit@testmail.app"},"contributors":[{"name":"Johannes Schickling","email":"johannes@graph.cool"}],"license":"MIT","bugs":{"url":"https://github.com/testmail-app/graphql-request/issues"},"homepage":"https://github.com/testmail-app/graphql-request","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d","lint":"eslint '{src,tests}/**/*.ts'","test":"npm run lint && npm run build && mocha \"./dist/tests/*.js\" && npm run size","size":"bundlesize"},"dependencies":{"cross-fetch":"^3.0.4","fetch-retry":"^3.1.0"},"devDependencies":{"@types/chai":"^4.2.11","@types/chai-as-promised":"^7.1.2","@types/mocha":"^7.0.2","@types/node":"^13.11.0","@typescript-eslint/eslint-plugin":"^2.26.0","@typescript-eslint/parser":"^2.26.0","bundlesize":"^0.18.0","chai":"^4.2.0","chai-as-promised":"^7.1.1","eslint":"^6.8.0","eslint-plugin-mocha":"^6.3.0","mocha":"^7.1.1","nock":"^12.0.3","typescript":"^3.8.3"},"gitHead":"3e1b4bf96548950732251cd76664f7cb5f87a5a2","_id":"@testmail.app/graphql-request@1.8.3","_nodeVersion":"13.11.0","_npmVersion":"6.13.7","dist":{"integrity":"sha512-r8f/qFnEN6L6PGbwB4EjcCqSlkSv7LR1GXDVuOK5oQYLIh3CC3ScQyYjb77xntsWlFgAZ530DYN9qs9BHrxZ5Q==","shasum":"e9bf5e43547d8094a0521a7bb680f03837394564","tarball":"https://registry.npmjs.org/@testmail.app/graphql-request/-/graphql-request-1.8.3.tgz","fileCount":12,"unpackedSize":38899,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJejMYlCRA9TVsSAnZWagAAR0UP/ifKAkHWteEIgQLst91F\nPLc9jBGY/3Dd49+e9kdL9ZFC0kx8mpU0APre5VcYsJO4fM3HtzoXwwvXAJ5r\nWDsbIWLt08axdh25+N+Sg+nPDZE5P8eIeVfk8A116JCT9dTjKNPPxwt+SvaG\ncBUeiQDhbfQDwb9OK/Z/b5CFM/nO/jBF6cK2xeRKnPMjk+0qHsXQiGUlAJJz\nGTkVbRr4Ve9XCU+5+8p+/UGKLYZNK9pYWGzYRjPHNclvPNPpmXGsk0O4BvfI\ngs1PEB7rTL3UgP906yd+AZZ9q8lCxKL2qrw8KsMWVkDDVJZgXArmwT0UKMYM\nrxa40/BEj0P1Xq+BKLL+KXu4irTrevkIUkgDtkOdbz+gOLM9+SGEnzr61ZEb\nGTvE6ozpTa3ySW80f6HJx5OtBCnm7MDtON7hS63O95AWwBwABXdqHgNPR3n2\n2ztKBQwfFpjrvqYt7xa1DNh5HV6b1kHxWhkjriWxt8sg96tt1AVQF7ORIjLM\n1IK7pzVWocrd7KUc67YMUpRgvxG1gjJoo9rguA/DB7dd8XuZTliJ7jL380fR\ndoRRimHDpfGQiC7jFR6Alfsn835/GQWMiCdTrwH49KWDYn6rg7xkkPjJOh1u\nJRYk3wDYfsULJYN4DzOLnEeztR58DYzenLCaPuHsB11shzC41SZIxeN11fbL\nZRaH\r\n=mZDC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAVy9CYZ4zexR6q4X6SMLDBvtDana9PNKyQADBuPpIifAiEAzKrOIrtWyjyKTo1l9uh3DE7n6UsAhZzNvJkdEsFKbaY="}]},"maintainers":[{"name":"amit-a","email":"amit@testmail.app"}],"_npmUser":{"name":"amit-a","email":"amit@testmail.app"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-request_1.8.3_1586284069113_0.7811061199614056"},"_hasShrinkwrap":false},"1.8.4":{"name":"@testmail.app/graphql-request","description":"Clone of graphql-request (minimal GraphQL client) with improvements like built-in retries","version":"1.8.4","main":"dist/src/index.js","typings":"./dist/src/index.d.ts","bundlesize":[{"path":"./dist/src/index.js","maxSize":"15 kB"}],"repository":{"type":"git","url":"git+https://github.com/testmail-app/graphql-request.git"},"keywords":["graphql","request","fetch","graphql-client","apollo","typescript"],"author":{"name":"Amit","email":"amit@testmail.app"},"contributors":[{"name":"Johannes Schickling","email":"johannes@graph.cool"}],"license":"MIT","bugs":{"url":"https://github.com/testmail-app/graphql-request/issues"},"homepage":"https://github.com/testmail-app/graphql-request","scripts":{"prepublish":"npm run build","build":"rm -rf dist && tsc -d","lint":"eslint '{src,tests}/**/*.ts'","test":"npm run lint && npm run build && mocha \"./dist/tests/*.js\" && npm run size","size":"bundlesize"},"dependencies":{"cross-fetch":"^3.0.4","fetch-retry":"^3.1.0"},"devDependencies":{"@types/chai":"^4.2.11","@types/chai-as-promised":"^7.1.2","@types/mocha":"^7.0.2","@types/node":"^13.11.0","@typescript-eslint/eslint-plugin":"^2.26.0","@typescript-eslint/parser":"^2.26.0","bundlesize":"^0.18.0","chai":"^4.2.0","chai-as-promised":"^7.1.1","eslint":"^6.8.0","eslint-plugin-mocha":"^6.3.0","mocha":"^7.1.1","nock":"^12.0.3","typescript":"^3.8.3"},"gitHead":"30403199e6f773e78c3b6f6abeb069d6d09c8bf8","_id":"@testmail.app/graphql-request@1.8.4","_nodeVersion":"13.11.0","_npmVersion":"6.13.7","dist":{"integrity":"sha512-tHTXfoSLNlZJIKLI/6lpNYriIqigg8Ga8JRatY3978YL4hEvt5DswcRPFAd2O3v/ulv5OfAIzWF66Z5XteNfFw==","shasum":"76ea8409e2e7a09bd78ce403a82ebe52ee372e5d","tarball":"https://registry.npmjs.org/@testmail.app/graphql-request/-/graphql-request-1.8.4.tgz","fileCount":12,"unpackedSize":39058,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJejMhZCRA9TVsSAnZWagAA/Y0QAKM4i3Fxxt7bA6iPUmFG\n6XFDWj1af3xE2kwm92fC3XWy3TVeg/6oGw2aF9iltGIuLq234fxP9SFnosOQ\nBRcFkKYqIOplo1a4vJtWVeP3FHXsEYlDNDG7RbA8/wzy+Ki7KPGxoFz4GtqL\na0G/V8xBaH0tCb0g57Jg/1FS0AkTNN6sglTUuD9OkccRUNsu8q5+KiwEKC2Z\ne36IUGsDIgk40nHfaVZ7fyYE7ep73hC21vLHiGtmYTqIwBhviFL/450nfH9g\nEJMvypeYu6suLI463BWrJsFa/Tl0WLmeqmXBTEB7BziI/j54atvaSdhB4mkE\nRSZOz5nP2hFybRrCsvqD1LVaLwyACaZwI7bYQDBi8wR6pw9uWwwrGLccarql\n54jWFy5r4pSNBEx3xxprLr+R6VW/mXnxO82kRp6sRltxW/aqhBXbYPAFyBTk\n98qqmy+/IYWjfgywIsqgE97DfR0LJnfy3Mtgk2PL4LO00kbz3XbFhzmK6cvH\nvCjEaOIcOxGewE4rA9LiQr4OjnxVRtuGodTKRFpUwAgd77c6vKTuoyp/ZB2V\nROp3h9a589g3hPD3KIM4ojm+/Zk11SrSswtTwpDe5iZBK4t94CBhW3qvZ1di\n7OTKHUL2eQIoOp0kZwdIVx1T+lwcOsuE5k6fWMixg3hak5LREEPUJwPJqleQ\nkcVi\r\n=6lVv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCSYkt3DHP50awVuXvK06Tj19J8Z89rZNABqKtvHstToAIhAPRhyBOXMrDoOzmAmda1SnyNsd9Ugx98Z8st3SylSZO8"}]},"maintainers":[{"name":"amit-a","email":"amit@testmail.app"}],"_npmUser":{"name":"amit-a","email":"amit@testmail.app"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graphql-request_1.8.4_1586284632853_0.25472441784125177"},"_hasShrinkwrap":false}},"time":{"created":"2020-04-07T18:27:48.854Z","1.8.3":"2020-04-07T18:27:49.227Z","modified":"2022-04-07T05:22:44.799Z","1.8.4":"2020-04-07T18:37:13.027Z"},"maintainers":[{"name":"amit-a","email":"amit@testmail.app"}],"description":"Clone of graphql-request (minimal GraphQL client) with improvements like built-in retries","homepage":"https://github.com/testmail-app/graphql-request","keywords":["graphql","request","fetch","graphql-client","apollo","typescript"],"repository":{"type":"git","url":"git+https://github.com/testmail-app/graphql-request.git"},"contributors":[{"name":"Johannes Schickling","email":"johannes@graph.cool"}],"author":{"name":"Amit","email":"amit@testmail.app"},"bugs":{"url":"https://github.com/testmail-app/graphql-request/issues"},"license":"MIT","readme":"# @testmail.app/graphql-request\n\n![GitHubCI](https://github.com/testmail-app/graphql-request/workflows/ci/badge.svg) [![npm version](https://badge.fury.io/js/%40testmail.app%2Fgraphql-request.svg)](https://badge.fury.io/js/%40testmail.app%2Fgraphql-request)\n\nClone of [graphql-request](https://github.com/prisma-labs/graphql-request) (minimal GraphQL client) with improvements like built-in retries.\n\n## Highlights\n\n- **Simple and lightweight** GraphQL client with a promise-based API (works with `async` / `await`) and typescript support\n- API compatible with [graphql-request](https://github.com/prisma-labs/graphql-request) (no breaking changes; drop-in replacement)\n- Configurable retries (see docs below)\n\n## Install\n\n```sh\nnpm install @testmail.app/graphql-request\n```\n\n## Quickstart\n\n```js\nimport { request } from '@testmail.app/graphql-request'\n\nconst query = `{\n  Movie(title: \"Inception\") {\n    releaseDate\n    actors {\n      name\n    }\n  }\n}`;\n\nrequest('https://api.graph.cool/simple/v1/movies', query).then(data =>\n  console.log(data)\n);\n```\n\n## Usage (with retries)\n\n```js\nimport { request, GraphQLClient } from '@testmail.app/graphql-request'\n\n// Run GraphQL queries/mutations using a static function\nrequest(endpoint, query, variables).then(data => console.log(data));\n\n// ... or create a GraphQL client instance to send requests\nconst client = new GraphQLClient(endpoint, { headers: {} });\nclient.request(query, variables).then(data => console.log(data));\n\n// This is the default retry policy:\nconst client = new GraphQLClient(endpoint, {\n  retries: 9,\n  retryDelay: function (attempt) {\n    // Exponential backoff: 1s, 2s, 4s, etc. upto 40s (max)\n    return Math.min(Math.pow(2, attempt) * 1000, 40000);\n  },\n  retryOn: [500, 502, 503, 504] // response status codes to retry on\n  // network connection errors are always retried\n});\n```\n\nTo override the default retry policy, replace any of those three arguments: `retries`, `retryDelay`, and `retryOn`.\n\nThe options object (2nd argument to GraphQLClient constructor) passes along any additional parameters to [fetch](https://github.github.io/fetch/) - so you can easily configure the underlying fetch API :)\n\n## Examples\n\n### Authentication via HTTP header\n\n```js\nimport { GraphQLClient } from '@testmail.app/graphql-request'\n\nasync function main() {\n  const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'\n\n  const graphQLClient = new GraphQLClient(endpoint, {\n    headers: {\n      authorization: 'Bearer MY_TOKEN',\n    },\n  })\n\n  const query = /* GraphQL */ `\n    {\n      Movie(title: \"Inception\") {\n        releaseDate\n        actors {\n          name\n        }\n      }\n    }\n  `\n\n  const data = await graphQLClient.request(query)\n  console.log(JSON.stringify(data, undefined, 2))\n}\n\nmain().catch(error => console.error(error))\n```\n\n### Passing more options to fetch\n\n```js\nimport { GraphQLClient } from '@testmail.app/graphql-request'\n\nasync function main() {\n  const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'\n\n  const graphQLClient = new GraphQLClient(endpoint, {\n    credentials: 'include',\n    mode: 'cors',\n  })\n\n  const query = /* GraphQL */ `\n    {\n      Movie(title: \"Inception\") {\n        releaseDate\n        actors {\n          name\n        }\n      }\n    }\n  `\n\n  const data = await graphQLClient.request(query)\n  console.log(JSON.stringify(data, undefined, 2))\n}\n\nmain().catch(error => console.error(error))\n```\n\n### Using variables\n\n```js\nimport { request } from '@testmail.app/graphql-request'\n\nasync function main() {\n  const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'\n\n  const query = /* GraphQL */ `\n    query getMovie($title: String!) {\n      Movie(title: $title) {\n        releaseDate\n        actors {\n          name\n        }\n      }\n    }\n  `\n\n  const variables = {\n    title: 'Inception',\n  }\n\n  const data = await request(endpoint, query, variables)\n  console.log(JSON.stringify(data, undefined, 2))\n}\n\nmain().catch(error => console.error(error))\n```\n\n### Error handling\n\n```js\nimport { request } from '@testmail.app/graphql-request'\n\nasync function main() {\n  const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'\n\n  const query = /* GraphQL */ `\n    {\n      Movie(title: \"Inception\") {\n        releaseDate\n        actors {\n          fullname # \"Cannot query field 'fullname' on type 'Actor'. Did you mean 'name'?\"\n        }\n      }\n    }\n  `\n\n  try {\n    const data = await request(endpoint, query)\n    console.log(JSON.stringify(data, undefined, 2))\n  } catch (error) {\n    console.error(JSON.stringify(error, undefined, 2))\n    process.exit(1)\n  }\n}\n\nmain().catch(error => console.error(error))\n```\n\n### Using `require` instead of `import`\n\n```js\nconst { request } = require('graphql-request')\n\nasync function main() {\n  const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'\n\n  const query = /* GraphQL */ `\n    {\n      Movie(title: \"Inception\") {\n        releaseDate\n        actors {\n          name\n        }\n      }\n    }\n  `\n\n  const data = await request(endpoint, query)\n  console.log(JSON.stringify(data, undefined, 2))\n}\n\nmain().catch(error => console.error(error))\n```\n\n### Receiving a raw response\n\nThe `request` method will return the `data` or `errors` key from the response.\nIf you need to access the `extensions` key you can use the `rawRequest` method:\n\n```js\nimport { rawRequest } from '@testmail.app/graphql-request'\n\nasync function main() {\n  const endpoint = 'https://api.graph.cool/simple/v1/cixos23120m0n0173veiiwrjr'\n\n  const query = /* GraphQL */ `\n    {\n      Movie(title: \"Inception\") {\n        releaseDate\n        actors {\n          name\n        }\n      }\n    }\n  `\n\n  const { data, errors, extensions, headers, status } = await rawRequest(\n    endpoint,\n    query\n  )\n  console.log(\n    JSON.stringify({ data, errors, extensions, headers, status }, undefined, 2)\n  )\n}\n\nmain().catch(error => console.error(error))\n```\n","readmeFilename":"README.md"}