Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
A

apollo-link-rest

> 编程语言
Open source

Use existing REST endpoints with GraphQL

785 stars0 likes2 views
WebsiteGitHub

About

Use existing REST endpoints with GraphQL


title: REST Link

⚠️ This library is under active development ⚠️

The Apollo Link Rest library is maintained by Apollo community members and not an Apollo GraphQL maintained library. For information on progress check out the issues or the design. We would love your help with writing docs, testing, anything! We would love for you, yes you, to be a part of the Apollo community!

Purpose

An Apollo Link to easily try out GraphQL without a full server. It can be used to prototype, with third-party services that don't have a GraphQL endpoint or in a transition from REST to GraphQL.

Installation

bash
npm install apollo-link-rest @apollo/client graphql qs --save
or
yarn add apollo-link-rest @apollo/client graphql qs

@apollo/client, graphql, and qs are peer dependencies needed by apollo-link-rest.

Usage

Basics

…

Apollo Client & React Apollo

For an example of using REST Link with Apollo Client and React Apollo view this CodeSandbox:

TypeScript

For an example of using REST Link with Apollo Client, React Apollo and TypeScript view this CodeSandbox:

Options

REST Link takes an object with some options on it to customize the behavior of the link. The options you can pass are outlined below:

  • uri: the URI key is a string endpoint (optional when endpoints provides a default)
  • endpoints: root endpoint (uri) to apply paths to or a map of endpoints
  • customFetch: a custom fetch to handle REST calls
  • headers: an object representing values to be sent as headers on the request
  • credentials: a string representing the credentials policy you want for the fetch call
  • fieldNameNormalizer: function that takes the response field name and converts it into a GraphQL compliant name

Context

REST Link uses the headers field on the context to allow passing headers to the HTTP request. It also supports the credentials field for defining credentials policy.

  • headers: an object representing values to be sent as headers on the request
  • credentials: a string representing the credentials policy you want for the fetch call

Documentation

For a complete apollo-link-rest reference visit the documentation website at: https://www.apollographql.com/docs/link/links/rest.html

Contributing

This project uses TypeScript to bring static types to JavaScript and uses Jest for testing. To get started, clone the repo and run the following commands:

bash
npm install # or `yarn`

npm test # or `yarn test` to run tests
npm test -- --watch # run tests in watch mode

npm run check-types # or `yarn check-types` to check TypeScript types

To run the library locally in another project, you can do the following:

bash
npm link

# in the project you want to run this in
npm link apollo-link-rest

Related Libraries

  • JSON API Link provides tooling for using GraphQL with JSON API compliant APIs.
  • apollo-type-patcher declarative type definitions for your REST API with zero dependencies.

Issues· 41 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScript

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言