{"name":"apollo-link","version":"1.2.10","description":"Flexible, lightweight transport layer for GraphQL","author":{"name":"Evans Hauser","email":"evanshauser@gmail.com"},"contributors":[{"name":"James Baxley","email":"james@meteor.com"},{"name":"Jonas Helfer","email":"jonas@helfer.email"},{"name":"jon wong","email":"j@jnwng.com"},{"name":"Sashko Stubailo","email":"sashko@stubailo.com"}],"license":"MIT","main":"./lib/index.js","module":"./lib/bundle.esm.js","typings":"./lib/index.d.ts","sideEffects":false,"repository":{"type":"git","url":"git+https://github.com/apollographql/apollo-link.git"},"bugs":{"url":"https://github.com/apollographql/apollo-link/issues"},"homepage":"https://github.com/apollographql/apollo-link#readme","scripts":{"build":"tsc && rollup -c","clean":"rimraf lib/* && rimraf coverage/*","coverage":"jest --coverage","filesize":"../../scripts/minify","lint":"tslint -c \"../../tslint.json\" -p tsconfig.json -c ../../tslint.json src/*.ts","prebuild":"npm run clean","prepare":"npm run build","test":"npm run lint && jest","watch":"tsc -w -p . & rollup -c -w"},"dependencies":{"apollo-utilities":"^1.2.1","ts-invariant":"^0.3.2","tslib":"^1.9.3","zen-observable-ts":"^0.8.17"},"peerDependencies":{"graphql":"^0.11.3 || ^0.12.3 || ^0.13.0 || ^14.0.0"},"devDependencies":{"@types/graphql":"14.0.7","@types/jest":"24.0.11","@types/node":"9.6.42","graphql":"14.1.1","graphql-tag":"2.10.1","jest":"24.5.0","rimraf":"2.6.3","rollup":"1.6.0","ts-jest":"22.4.6","tslint":"5.13.1","typescript":"3.0.3"},"jest":{"transform":{".(ts|tsx)":"ts-jest"},"testRegex":"(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$","moduleFileExtensions":["ts","tsx","js","json"],"testURL":"http://localhost"},"gitHead":"127ab65ba89185a82c492299c7853f02fdd7e570","_id":"apollo-link@1.2.10","_nodeVersion":"8.12.0","_npmVersion":"lerna/3.13.1/node@v8.12.0+x64 (darwin)","dist":{"integrity":"sha512-vQ5u+jEHyLJaV+eUoVKFYYiJcCY9dBNSNhf7Ve9YxeFf84ZDt5NNOPXQEygF39qdoqFRYJb7OkAOJptydteOvw==","shasum":"98cf24c46c0d75cb878804143e39dcf9813f0c20","tarball":"http://registry-npm.ywwl.com/apollo-link/download/apollo-link-1.2.10.tgz","fileCount":42,"unpackedSize":99125,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJciaqgCRA9TVsSAnZWagAAYQcQAJQMA2tR15FRQhETT8mn\nSyy+/vEy7330w/GqNWFQdnzrphljtKa7ZKp1nqko4nnYpaEHPEIN+avCNupZ\ncoUs5042y6LY6NW7xkWZFvO1D89biaHrVOQwSz84S88h3nhBfrL7U1S+4dUS\npyd1MU4EccEKYE2z/LrClRP2/GBc0qP3N/9iuaszbGoxj8uzv10t99r+Ipsq\n+vUrXzVGpd5IwzStGCbdbk+n7E1r+1XBj9zNhMeBiK8E+8AKKdUr5PDVTXiI\nNJ4RQCPPy6doLJjY9x/MTbCpzt77ErRofSkAkUI6FE0/J62hqLW2sp+TyXCX\nozaL65Bw/Coh3UI7Xp/a6iaruY5u36w+CdBwKX12dlUU7MymXm1UHBgjDVfD\nWmURm6ajf7C8YmQmwDMMSjVsoybKZoox9Ww62Ccpc3hNASI+Pt7eKei5j7Hz\nm0x9R7ggLV89iHUqD5NSBROndrJtrmgoFhpD4wpt+bRTa4Vdbg1JsrdIXCGQ\n2MfekuIM6r31JvyITKbF3ngRFplgD35mUXo+4zM8m30Y4PDAmvXVypZMAyXr\nAlQHqK78/9biO+Ygt75h+mPZ9bjH5LrQ6LALNuAvU0FDZV4e67D2hV/Of0jN\nQmSjbSy4VeTtSrKLw/NspWiXXOnDVX5/ewXBW4EOlSmJzkhcvsdV6QIscPE8\ngvyw\r\n=uMI0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD3DHEsALnG2cZTduAUAS7DstldgpCzXsaO8jvCE3F3jwIhAMzOBj3aWOunreRR2tx/PCydw+85xgtnIKNQCZb3B9ls"}],"size":18860,"noattachment":false,"key":"/apollo-link/-/apollo-link-1.2.10.tgz"},"maintainers":[{"email":"npm@apollographql.com","name":"apollo-bot"},{"email":"evanshauser@gmail.com","name":"evanshauser"},{"email":"james@meteor.com","name":"jbaxleyiii"},{"email":"peggyrayzis@gmail.com","name":"peggyrayzis"}],"_npmUser":{"name":"apollo-bot","email":"npm@apollographql.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apollo-link_1.2.10_1552525983671_0.6385436807449363"},"_hasShrinkwrap":false,"readme":"# apollo-link\r\n\r\n## Purpose\r\n\r\n`apollo-link` is a standard interface for modifying control flow of GraphQL requests and fetching GraphQL results, designed to provide a simple GraphQL client that is capable of extensions.\r\nThe targeted use cases of `apollo-link` are highlighted below:\r\n\r\n* fetch queries directly without normalized cache\r\n* network interface for Apollo Client\r\n* network interface for Relay Modern\r\n* fetcher for\r\n\r\nApollo Link is the interface for creating new links in your application.\r\n\r\nThe client sends a request as a method call to a link and can recieve one or more (in the case of subscriptions) responses from the server. The responses are returned using the Observer pattern.\r\n\r\n![Apollo Link Chain](https://cdn-images-1.medium.com/max/1600/1*62VLGUaU-9ULCoBCGvgdkQ.png)\r\n\r\nResults from the server can be provided by calling `next(result)` on the observer. In the case of a network/transport error (not a GraphQL Error) the `error(err)` method can be used to indicate a response will not be recieved. If multiple responses are not supported by the link, `complete()` should be called to inform the client no further data will be provided.\r\n\r\nIn the case of an intermediate link, a second argument to `request(operation, forward)` is the link to `forward(operation)` to. `forward` returns an observable and it can be returned directly or subscribed to.\r\n\r\n```js\r\nforward(operation).subscribe({\r\n  next: result => {\r\n    handleTheResult(result)\r\n  },\r\n  error: error => {\r\n    handleTheNetworkError(error)\r\n  },\r\n});\r\n```\r\n\r\n## Implementing a basic custom transport\r\n\r\n```js\r\nimport { ApolloLink, Observable } from 'apollo-link';\r\n\r\nexport class CustomApolloLink extends ApolloLink {\r\n  request(operation /*, forward*/) {\r\n    //Whether no one is listening anymore\r\n    let unsubscribed = false;\r\n\r\n    return new Observable(observer => {\r\n      somehowGetOperationToServer(operation, (error, result) => {\r\n        if (unsubscribed) return;\r\n        if (error) {\r\n          //Network error\r\n          observer.error(error);\r\n        } else {\r\n          observer.next(result);\r\n          observer.complete(); //If subscriptions not supported\r\n        }\r\n      });\r\n\r\n      function unsubscribe() {\r\n        unsubscribed = true;\r\n      }\r\n\r\n      return unsubscribe;\r\n    });\r\n  }\r\n}\r\n```\r\n\r\n## Installation\r\n\r\n`npm install apollo-link --save`\r\n\r\n","publish_time":1552525983816,"_cnpm_publish_time":1552525983816,"dist-tags":{"alpha":"1.2.9-alpha.1","beta":"0.6.1-beta.6","latest":"1.2.14","prerelease":"1.0.2"}}