REST Link
⚠️ This library is under active development ⚠️
Purpose
Installation
npm install apollo-link-rest apollo-link graphql graphql-anywhere qs --save
or
yarn add apollo-link-rest apollo-link graphql graphql-anywhere qsUsage
Basics
import { RestLink } from "apollo-link-rest";
// Other necessary imports...
// Create a RestLink for the REST API
// If you are using multiple link types, restLink should go before httpLink,
// as httpLink will swallow any calls that should be routed through rest!
const restLink = new RestLink({
uri: 'https://swapi.co/api/',
});
// Configure the ApolloClient with the default cache and RestLink
const client = new ApolloClient({
link: restLink,
cache: new InMemoryCache(),
});
// A simple query to retrieve data about the first person
const query = gql`
query luke {
person @rest(type: "Person", path: "people/1/") {
name
}
}
`;
// Invoke the query and log the person's name
client.query({ query }).then(response => {
console.log(response.data.person.name);
});Apollo Client & React Apollo
TypeScript
Options
Context
Documentation
Contributing
Related Libraries
Last updated