{"name":"apollo-link","version":"1.2.9-alpha.1","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","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:browser":"browserify ./lib/bundle.umd.js -o=./lib/bundle.js --i graphql --i zen-observable-ts && npm run minify:browser","build":"tsc -p ./tsconfig.cjs.json","bundle":"rollup -c","clean":"rimraf lib/* && rimraf coverage/*","coverage":"jest --coverage","filesize":"npm run build && npm run build:browser","lint":"tslint -c \"../../tslint.json\" -p tsconfig.json -c ../../tslint.json src/*.ts","minify:browser":"uglifyjs -c -m -o ./lib/bundle.min.js -- ./lib/bundle.js","postbuild":"npm run bundle","prebuild":"npm run clean","prepare":"npm run lint && npm run build","prepublishOnly":"npm run clean && npm run build","test":"jest","watch":"tsc -w -p . & rollup -c -w"},"dependencies":{"zen-observable-ts":"^0.8.15"},"peerDependencies":{"graphql":"^0.11.3 || ^0.12.3 || ^0.13.0 || ^14.0.0"},"devDependencies":{"@types/graphql":"14.0.5","@types/jest":"22.2.3","@types/node":"9.6.41","browserify":"16.2.3","graphql":"14.1.1","graphql-tag":"2.10.1","jest":"22.4.4","rimraf":"2.6.3","rollup":"0.68.2","ts-jest":"22.4.6","tslint":"5.12.1","typescript":"3.0.3","uglify-js":"3.4.9"},"jest":{"transform":{".(ts|tsx)":"ts-jest"},"testRegex":"(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$","moduleFileExtensions":["ts","tsx","js","json"],"testURL":"http://localhost"},"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\nclass import { 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","readmeFilename":"README.md","_id":"apollo-link@1.2.9-alpha.1","_npmVersion":"6.4.1","_nodeVersion":"8.12.0","_npmUser":{"name":"apollo-bot","email":"npm@apollographql.com"},"dist":{"integrity":"sha512-Ht+N9s69KbNEVnO2w22Hkw0525yx2Tk7hEyl1NzlkR9Pqo6sCVxA037iGGP/WdYuUmExGkBwsmQPgLUQXqMQag==","shasum":"f3ce7f50436f18749e3727a0faee773136289559","tarball":"http://registry-npm.ywwl.com/apollo-link/download/apollo-link-1.2.9-alpha.1.tgz","fileCount":40,"unpackedSize":108081,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcVLg3CRA9TVsSAnZWagAAL4QQAIJ7L+iFo5QSVWinX6Cp\nHcjjSbu6NpUgWV/l7RRhS0E6erVb9ouSW51Prf0LGF87ymcxX9DRayj1QhK1\nvsl4veaXO28n6wOKRDvP0NLcj5M7uqQiz6wqtZetkpkqaYyzO6PUTm7GVYy2\nRwZ1nzkYPijWmPSCel5TLF17JDkvixDKag5mcHDSwYiJb6YZgn7/0EXPOQs9\nKXT78lOvkqjRnIQjrlBQ7JM/KhcFAyo64bnKVTRVHn/e2LYOfaoDwMrikIyq\naccsGFc85tc9O4K0f4PUkAd5S7WEIUNYZfNZtVnWNNc0rk9x/w1NARCaHQLU\ntVgdInW9ZOxhn15cxHRz5cK1kfsBZ5WMjT3yBCFt8eL/8NghkEal0Ws+p/GS\nCovabTl4iIrTVW/odv0ZigNbn7rcqtXhEy8uc7hbDKfdu41eHCTzWJuVJTTG\n2JhIaKlo461wV+DY5FntHXbZyXgvqSgZY4vXumvx6aclBLInnsMD9pOm9CMq\nzuZD2ChfB21a6ekiP4Il7eDtizWPavLCGdPgDvcXy+ZnuSLrq5Rh7UIDsZzs\nHy4UqWf1liBTkFLA+P6sif0T6aG49XeelapATemCdex0MHlkjG/N4ryUdcTt\nUXPkkXLf8sdwNTvgehHNfAY0rc6jRJpq/MUTSxcBNuM3jdm6b87bDHIoaIsh\nM64D\r\n=pe6e\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDWyaA/QXEUGeZ+eQ2RadLCG1kES3y4qe6+awtAxahGfwIhALLqsaWrv2U5O49IDErOYEVHddSyinR6Qh4NU6efJbF6"}],"size":25653,"noattachment":false,"key":"/apollo-link/-/apollo-link-1.2.9-alpha.1.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"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apollo-link_1.2.9-alpha.1_1549056055056_0.712851242359146"},"_hasShrinkwrap":false,"publish_time":1549056055189,"_cnpm_publish_time":1549056055189,"dist-tags":{"alpha":"1.2.9-alpha.1","beta":"0.6.1-beta.6","latest":"1.2.14","prerelease":"1.0.2"}}