{"name":"graphql-request","version":"4.2.0","keywords":["graphql","request","fetch","graphql-client","apollo"],"author":{"name":"Prisma Labs Team"},"license":"MIT","_id":"graphql-request@4.2.0","homepage":"https://github.com/prisma/graphql-request","bugs":{"url":"https://github.com/prisma/graphql-request/issues"},"dist":{"shasum":"063377bc2dd29cc46aed3fddcc65fe97b805ba81","tarball":"http://registry-npm.ywwl.com/graphql-request/download/graphql-request-4.2.0.tgz","fileCount":30,"integrity":"sha512-uFeMyhhl8ss4LFgjlfPeAn2pqYw+CJto+cjj71uaBYIMMK2jPIqgHm5KEFxUk0YDD41A8Bq31a2b4G2WJBlp2Q==","signatures":[{"sig":"MEQCIBLgvRm8E58Dg5goxeFz04PJora8dANIa1rba/pGYy2GAiBr09+niTKoL3dJ7WsSgH0LBUNaVGOVYE+OLgsxFV9bnQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":130688,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiOxSYACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmo6wg/+LNGpINjG331MxF+jOly8JVfWpjwAaFhfpXM30b2ZNjwLrFDp\r\nnvHG+EO1aKcIpmhnnw9c11coL23qTceaRVy1/HoUXXmJUzfFZJ+cDLIUQaL0\r\nFP4uf+Zx/Zp1LhRRF78b9R6SuXbLfQUV/3NL/c91Yom7mpED1BpkCcC05u95\r\nPIKEBEBipy6jLdTyZa9DeAhRWtqXLCCyPJoWBiKO7C8lrLwgRL+SSIUCFEXJ\r\nOLUbJhlvY12aBtwwlth0PSR03TLOX0DYKih3uUF4YUUxPN4o4QPZVbjl+KDq\r\nZi4O8CBi23DvawDL7CRczTjkfUNGvwOZ+UHZtFV4AA7W0HSQh/zUythUfhWu\r\nJtITP9zv/DEjmTIbLZoqdl7o3PVII9YKzpUOKRReuGU5n7FDJCS7VrgkDo45\r\nNMtysOOBLw62ABtLDtwwKepw2LgeImg59nLLtnbgwjvXLZSAKnWXhwsAbwJe\r\ny6Rw1bHr6LHNY+cLcxRiCcHmnrw/KfUhJhyH2o1sgoxyjACJNvlph46cyen1\r\nR4SG5JNddpQAQPE6NHjpcm96SV2fkBCW1N4n2o6y6RCXLDkAChev+CelGPFf\r\nKBGxEFfhXQLDhljxeRleVygoFRr1HhmFBoffBIknbCEjoQPYxQKhQW6jSQDX\r\nSnzBaLPAM0++Pjiu1LqTC7YeXBViTv0c+w0=\r\n=iJ2K\r\n-----END PGP SIGNATURE-----\r\n","size":32604,"noattachment":false,"key":"/graphql-request/-/graphql-request-4.2.0.tgz"},"jest":{"preset":"ts-jest","snapshotResolver":"<rootDir>/snapshot-resolver.js"},"main":"dist/index.js","scripts":{"dev":"rm -rf dist && tsc --watch","test":"yarn test:node && yarn test:dom","build":"rm -rf dist && tsc -d","format":"prettier --write .","dev:test":"jest --watch","test:dom":"jest --testEnvironment jsdom","test:node":"jest --testEnvironment node","build:docs":"doctoc README.md --notitle","release:pr":"dripip pr","test:coverage":"yarn test --coverage","prepublishOnly":"yarn build","release:stable":"dripip stable","release:preview":"dripip preview"},"_npmUser":{"name":"jasonkuhrt","email":"jasonkuhrt@me.com"},"prettier":"@prisma-labs/prettier-config","bundlesize":[{"path":"./dist/index.js","maxSize":"15 kB"}],"repository":{"url":"https://github.com/prisma/graphql-request.git","type":"git"},"description":"Minimal GraphQL client supporting Node and browsers for scripts or simple apps","directories":{},"licenseText":"MIT License\n\nCopyright (c) 2017 Graphcool\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","dependencies":{"form-data":"^3.0.0","cross-fetch":"^3.1.5","extract-files":"^9.0.0"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^27.0.6","doctoc":"^2.0.1","dripip":"^0.10.0","express":"^4.17.1","graphql":"16","ts-jest":"^27.0.4","get-port":"^5.1.1","prettier":"^2.3.2","type-fest":"^1.2.2","typescript":"^4.3.5","@types/jest":"^26.0.24","@types/node":"^16.4.3","body-parser":"^1.19.0","graphql-tag":"^2.12.5","fetch-cookie":"^1.0.0","@types/express":"^4.17.13","graphql-upload":"^12.0.0","abort-controller":"^3.0.0","@types/body-parser":"^1.19.1","@types/extract-files":"^8.1.1","@types/graphql-upload":"^8.0.6","apollo-server-express":"^3.5.0","@prisma-labs/prettier-config":"^0.1.0"},"peerDependencies":{"graphql":"14 - 16"},"_npmOperationalInternal":{"tmp":"tmp/graphql-request_4.2.0_1648039064854_0.9739772833297207","host":"s3://npm-registry-packages"},"readme":"# graphql-request\n\nMinimal GraphQL client supporting Node and browsers for scripts or simple apps.\n\n![GitHub Action](https://github.com/jasonkuhrt/graphql-request/workflows/trunk/badge.svg) [![npm version](https://badge.fury.io/js/graphql-request.svg)](https://badge.fury.io/js/graphql-request)\n\n<!-- START doctoc generated TOC please keep comment here to allow auto update -->\n<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->\n\n- [Highlights](#highlights)\n- [Install](#install)\n  - [TypeScript Setup](#typescript-setup)\n- [Quick Start](#quick-start)\n- [Examples](#examples)\n- [Node Version Support](#node-version-support)\n- [Reference](#reference)\n  - [Configuration](#configuration)\n    - [ErrorPolicy](#errorpolicy)\n      - [None (default)](#none-default)\n      - [Ignore](#ignore)\n      - [All](#all)\n  - [IgnoreOperationName](#ignoreoperationname)\n- [Knowledge Base](#knowledge-base)\n  - [Why was the file upload feature taken away? Will it return?](#why-was-the-file-upload-feature-taken-away-will-it-return)\n  - [Why do I have to install `graphql`?](#why-do-i-have-to-install-graphql)\n  - [Do I need to wrap my GraphQL documents inside the `gql` template exported by `graphql-request`?](#do-i-need-to-wrap-my-graphql-documents-inside-the-gql-template-exported-by-graphql-request)\n  - [What sets `graphql-request` apart from other clients like Apollo, Relay, etc.?](#what-sets-graphql-request-apart-from-other-clients-like-apollo-relay-etc)\n- [Project Stats](#project-stats)\n  - [Package Installs](#package-installs)\n  - [Repo Beats](#repo-beats)\n\n<!-- END doctoc generated TOC please keep comment here to allow auto update -->\n\n## Highlights\n\n- Most **simple & lightweight** GraphQL client\n- Promise-based API (works with `async` / `await`)\n- [Pure ESM package](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)\n- First class TypeScript support\n  - Including `TypedDocumentNode`\n- Isomorphic (works in both Node and Browsers)\n\n## Install\n\n```sh\nnpm add graphql-request graphql\n```\n\n#### TypeScript Setup\n\nThis package uses [`package.exports`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports). Therefore if you are a TypeScript user you must:\n\n1. have your `tsconfig.json` `moduleResolution` set to [`\"bundler\"`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#bundler) or [`\"node16\"`/`\"nodenext\"`](https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-nodenext-1).\n2. Have your `package.json` `type` set to `\"module\"`.\n\n## Quick Start\n\nSend a GraphQL document using a static request function:\n\n```js\nimport { gql, request } from 'graphql-request'\n\nconst document = gql`\n  {\n    company {\n      ceo\n    }\n  }\n`\nawait request('https://api.spacex.land/graphql/', document)\n```\n\nThe function can be passed a configuration object for more complex cases:\n\n```ts\nawait request({\n  url,\n  document,\n  variables,\n  requestHeaders,\n})\n```\n\nA class is available for constructing your own instances:\n\n```js\nimport { gql, GraphQLClient } from 'graphql-request'\n\nconst document = gql`\n  {\n    company {\n      ceo\n    }\n  }\n`\nconst endpoint = 'https://api.spacex.land/graphql/'\nconst client = new GraphQLClient(endpoint)\nawait client.request(document)\n```\n\n## Examples\n\n- Request:\n  - [Authentication via HTTP header](./examples/request-authentication-via-http-header.ts)\n  - [Method GET](./examples/request-method-get.ts)\n  - [Cancellation](./examples/request-cancellation.ts)\n  - [Headers Per Request (static)](./examples/request-headers-static-per-request.ts)\n  - [Headers Per Request (dynamic)](./examples/request-headers-dynamic-per-request.ts)\n  - [Handle Raw Response](./examples/request-handle-raw-response.ts)\n- GraphQL:\n  - [Document Variables](./examples/graphql-document-variables.ts)\n  - [Mutation](./examples/graphql-mutations.ts)\n  - [Batching Requests](./examples/graphql-batching-requests.ts)\n- Configuration:\n  - [Fetch: Passing Options](./examples/configuration-fetch-options.ts)\n  - [Custom JSON Serializer](./examples/configuration-request-json-serializer.ts)\n  - [Incremental: Set Endpoint](./examples/configuration-incremental-endpoint.ts)\n  - [Incremental: Set Request Headers](./examples/configuration-incremental-request-headers.ts)\n- TypeScript:\n  - [Use `TypedDocumentNode`](./examples/typescript-typed-document-node.ts)\n- Other:\n  - [Middleware](./examples/other-middleware.ts)\n  - [Error Handling](./examples/other-error-handling.ts)\n\n## Node Version Support\n\nWe only (officially) support [versions of Nodejs](https://github.com/nodejs/Release#release-schedule) of the following status:\n\n- Current\n- LTS\n- Maintenance _and end of life not yet reached_\n\nSo for example on Oct 24 2023 that would mean these versions: 18, 20, 21.\n\nAny issue that exists solely for an unsupported version of Nodejs will be rejected (not worked on).\n\n## Reference\n\n⚠️ This reference is incomplete. Check out the [examples](./examples/) for more reference material.\n\n### Configuration\n\n#### ErrorPolicy\n\nBy default GraphQLClient will throw when an error is received. However, sometimes you still want to resolve the (partial) data you received.\nYou can define `errorPolicy` in the `GraphQLClient` constructor.\n\n```ts\nconst client = new GraphQLClient(endpoint, { errorPolicy: 'all' })\n```\n\n##### None (default)\n\nAllow no errors at all. If you receive a GraphQL error the client will throw.\n\n##### Ignore\n\nIgnore incoming errors and resolve like no errors occurred\n\n##### All\n\nReturn both the errors and data, only works with `rawRequest`.\n\n### IgnoreOperationName\n\nOperationName has been introduced to address issues reported here [Support operation name](https://github.com/jasonkuhrt/graphql-request/issues/64),\nHowever, on certain occasions this information may not be needed in requests. In such cases, you might consider ignoring operationName to avoid the extraction steps currently performed by a parsing operation when the document is provided in string format.\n\nBy default the GraphQLClient tries to extract the operationName from the document.\nYou can define `excludeOperationName` in the constructor of GraphQLClient to avoid the extraction process if it is not needed. This can be useful if you don't use operationName and want to optimise queries by reducing the amount of computation as much as possible, especially if we are in a context where we are using documents in string format to reduce bundle size.\n\n```ts\n// example where the operation name is not ignored\nconst client = new GraphQLClient(endpoint, {\n  method: 'POST',\n})\n// example in which the operation name is ignored\nconst client = new GraphQLClient(endpoint, {\n  method: 'POST',\n  excludeOperationName: true,\n})\n```\n\n## Knowledge Base\n\n#### Why was the file upload feature taken away? Will it return?\n\nIn [this issue](https://github.com/jasonkuhrt/graphql-request/issues/500) we decided to make this library more stable and maintainable. In principal the feature is still in scope of this library and will make a return when we find time to do the feature right.\n\n#### Why do I have to install `graphql`?\n\n`graphql-request` uses methods exposed by the `graphql` package to handle some internal logic. On top of that, for TypeScript users, some types are used from the `graphql` package to provide better typings.\n\n#### Do I need to wrap my GraphQL documents inside the `gql` template exported by `graphql-request`?\n\nNo. It is there for convenience so that you can get the tooling support like automatic formatting and syntax highlighting. You can use `gql` from `graphql-tag` if you need it for some reason too.\n\n#### What sets `graphql-request` apart from other clients like Apollo, Relay, etc.?\n\n`graphql-request` is the most minimal and simplest to use GraphQL client. It's perfect for small scripts or simple apps.\n\nCompared to GraphQL clients like Apollo or Relay, `graphql-request` doesn't have a built-in cache and has no integrations for frontend frameworks. The goal is to keep the package and API as minimal as possible.\n\n## Project Stats\n\n### Package Installs\n\n<a href=\"https://npm-compare.com/graphql-request#timeRange=FIVE_YEARS\" target=\"_blank\">\n  <img src=\"https://npm-compare.com/img/npm-trend/FIVE_YEARS/graphql-request.png\" width=\"100%\" alt=\"NPM Usage Trend of graphql-request\" />\n</a>\n\n### Repo Beats\n\n![Alt](https://repobeats.axiom.co/api/embed/aeb7beaee43b190e90868357c5a2898f517fb63e.svg \"Repobeats analytics image\")\n","publish_time":1648039064998,"maintainers":[{"name":"schickling","email":"schickling.j@gmail.com"},{"name":"timsuchanek","email":"tim.suchanek@gmail.com"},{"name":"jasonkuhrt","email":"jasonkuhrt@me.com"},{"name":"divyenduz","email":"mail@divyendusingh.com"},{"name":"weakky","email":"rav4g3@hotmail.fr"}],"_cnpm_publish_time":1648039064998,"dist-tags":{"alpha":"1.3.5-alpha","latest":"7.4.0","next":"7.2.0-next.17","pr.183":"0.0.0-pr.183.1.70c5790"}}