{"name":"apollo-link","version":"0.5.2","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":"./dist/src/bundle.umd.js","module":"./dist/src/index.js","jsnext:main":"./dist/src/index.js","typings":"./dist/src/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":{"pretest":"npm run build-test","test":"npm run test-only --","posttest":"npm run lint","test-only":"mocha --reporter spec --full-trace dist/tests/tests.js","test-watch":"mocha --reporter spec --full-trace dist/tests/tests.js --watch","coverage":"istanbul cover ./node_modules/mocha/bin/_mocha -- --reporter dot --full-trace dist/tests/tests.js","postcoverage":"remap-istanbul --input coverage/coverage.json --type lcovonly --output coverage/lcov.info","lint":"tslint --type-check -p tsconfig.test.json src/*.ts && tslint --type-check -p tsconfig.test.json tests/*.ts","prebuild":"npm run clean:dist","build":"tsc -p .","build-test":"tsc -p tsconfig.test.json","postbuild":"npm run bundle","postbuild-test":"npm run bundle","bundle":"rollup -c","watch":"tsc -w -p .","clean":"npm run clean:dist && npm run clean:coverage","clean:dist":"rimraf dist/*","clean:coverage":"rimraf coverage/*","prepublishOnly":"npm run clean && npm run build"},"dependencies":{"apollo-link-batch":"^0.1.2","apollo-link-batch-http":"^0.1.2","apollo-link-core":"^0.5.2","apollo-link-dedup":"^0.3.2","apollo-link-http":"^0.5.2","apollo-link-polling":"^0.5.2","apollo-link-retry":"^0.5.2","apollo-link-set-context":"^0.5.2","apollo-link-ws":"^0.3.2"},"devDependencies":{"@types/chai":"4.0.4","@types/chai-as-promised":"0.0.31","@types/graphql":"0.10.2","@types/mocha":"2.2.42","@types/sinon":"2.3.3","chai":"4.1.1","chai-as-promised":"7.1.1","fetch-mock":"5.12.2","istanbul":"0.4.5","lodash":"4.17.4","mocha":"3.5.0","remap-istanbul":"0.9.5","rimraf":"2.6.1","rollup":"^0.45.2","sinon":"3.2.0","source-map-support":"0.4.16","subscriptions-transport-ws":"0.8.2","tslint":"5.7.0","typescript":"2.5.1"},"_id":"apollo-link@0.5.2","_npmVersion":"5.4.0","_nodeVersion":"8.1.2","_npmUser":{"name":"jbaxleyiii","email":"james@meteor.com"},"dist":{"integrity":"sha512-drA74XPVoy2LVwP586skvEmrCPrFKS0AQbLWcGPemoIcSCB/QLWLGpBRjDrIn8efQpllziQ0z5QzgTzY86E3oQ==","shasum":"99dc7f157fb69acd5dc1047d25d5d28f9d31c237","tarball":"http://registry-npm.ywwl.com/apollo-link/download/apollo-link-0.5.2.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGKwOAmuIdFEoYRbGltsjAoAPPSkr6spD9NChsOPLhEWAiEAhiEmAei0yL1D1pZvULkjPdOcX3CrcRSkePvA5NpiYCM="}],"size":3563,"noattachment":false,"key":"/apollo-link/-/apollo-link-0.5.2.tgz"},"maintainers":[{"name":"evanshauser","email":"evanshauser@gmail.com"},{"name":"jbaxleyiii","email":"james@meteor.com"},{"name":"mdg","email":"npm@meteor.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/apollo-link-0.5.2.tgz_1504746238682_0.5050014462321997"},"directories":{},"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":1504746239745,"_cnpm_publish_time":1504746239745,"dist-tags":{"alpha":"1.2.9-alpha.1","beta":"0.6.1-beta.6","latest":"1.2.14","prerelease":"1.0.2"}}