{"id":46968,"library":"apollo-link","title":"apollo-link","description":"Apollo Link is the 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. Version 1.2.14 is stable with no active development; consider using @apollo/client (v3+) which includes links natively. Differentiators: composable chain of middleware, Observable-based, supports subscriptions.","status":"deprecated","version":"1.2.14","language":"javascript","source_language":"en","source_url":"https://github.com/apollographql/apollo-link","tags":["javascript","typescript"],"install":[{"cmd":"npm install apollo-link","lang":"bash","label":"npm"},{"cmd":"yarn add apollo-link","lang":"bash","label":"yarn"},{"cmd":"pnpm add apollo-link","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency for GraphQL types and execution","package":"graphql","optional":false}],"imports":[{"note":"Default export in CJS, named export in ESM; ApolloLink class must be extended.","wrong":"const ApolloLink = require('apollo-link').default","symbol":"ApolloLink","correct":"import { ApolloLink } from 'apollo-link'"},{"note":"Named export, not default. Used for creating custom links.","wrong":"import Observable from 'apollo-link'","symbol":"Observable","correct":"import { Observable } from 'apollo-link'"},{"note":"execute function is part of apollo-link, not apollo-client.","wrong":"import { execute } from 'apollo-client'","symbol":"execute","correct":"import { execute } from 'apollo-link'"}],"quickstart":{"code":"import { ApolloLink, Observable } from 'apollo-link';\nimport { print } from 'graphql/language/printer';\n\nclass MyLink extends ApolloLink {\n  request(operation, forward) {\n    if (forward) return forward(operation);\n    return new Observable(observer => {\n      fetch('/graphql', {\n        method: 'POST',\n        headers: { 'Content-Type': 'application/json' },\n        body: JSON.stringify({ query: print(operation.query), variables: operation.variables })\n      })\n        .then(res => res.json())\n        .then(result => {\n          observer.next(result);\n          observer.complete();\n        })\n        .catch(err => observer.error(err));\n    });\n  }\n}\n\nconst link = new MyLink();\nlink.request({ query: '{ hello }', variables: {} }).subscribe({\n  next: console.log,\n  error: console.error\n});","lang":"typescript","description":"Creates a custom Apollo Link that sends GraphQL requests over HTTP using fetch, demonstrating Observable usage."},"warnings":[{"fix":"Migrate to @apollo/client and use ApolloClient with ApolloLink from that package.","message":"apollo-link is deprecated. Use @apollo/client which includes links natively.","severity":"deprecated","affected_versions":">=1.0"},{"fix":"Upgrade to @apollo/client which handles this correctly.","message":"Breaking change: Inline fragments inside @export directives fail in Apollo Link as of v1.2.4","severity":"breaking","affected_versions":">=1.2.4 <1.3.0"},{"fix":"Use import syntax: import { ApolloLink } from 'apollo-link'","message":"Common mistake: using `require('apollo-link')` returns default export as object with ApolloLink, Observable, etc. Named imports require destructuring.","severity":"gotcha","affected_versions":">=1.0"},{"fix":"Check if forward exists: if (forward) return forward(operation); else return new Observable(...)","message":"Common mistake: `forward` argument may be undefined if link is terminal. Must check before calling forward(operation).","severity":"gotcha","affected_versions":">=1.0"}],"env_vars":null,"search_vec":"'1.2.14':34 'activ':39 'apollo':2,4 'apollo-link':1 'apollo/client':43 'base':56 'capabl':30 'chain':51 'client':27 'compos':50 'consid':41 'control':12 'design':21 'develop':40 'differenti':49 'extens':32 'fetch':18 'flow':13 'graphql':15,19,26 'includ':46 'interfac':9 'javascript':59 'link':3,5,47 'middlewar':53 'modifi':11 'nativ':48 'observ':55 'observable-bas':54 'provid':23 'request':16 'result':20 'simpl':25 'stabl':36 'standard':8 'subscript':58 'support':57 'typescript':60 'use':42 'v3':44 'version':33","created_at":"2026-06-07T16:49:04.736376+00:00","updated_at":"2026-06-07T16:49:04.736376+00:00","problems":[{"fix":"Check if forward is defined before calling: if (forward) return forward(operation);","cause":"Calling forward(operation) without checking if forward exists in a terminal link.","error":"Uncaught TypeError: forward is not a function"},{"fix":"Run: npm install apollo-link graphql","cause":"Package not installed or not in node_modules.","error":"Module not found: Can't resolve 'apollo-link'"},{"fix":"Use: import { Observable } from 'apollo-link'","cause":"Importing Observable as default instead of named export.","error":"TypeError: Observable is not a constructor"},{"fix":"Use: const { ApolloLink } = require('apollo-link');","cause":"Using CommonJS require without destructuring in CJS environment.","error":"import { ApolloLink } from 'apollo-link' returns undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/apollographql/apollo-link#readme","github":"https://github.com/apollographql/apollo-link","docs":null,"changelog":null,"pypi":null,"npm":"apollo-link","openapi_spec":null,"status_page":null,"smithery":null,"categories":["api"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}