Apollo
BootcampFrontend2020-12-17
Apollo Server
apollo-server
The Apollo Server library which allows you to focus on defining the shape of your data and how to fetch it.
graphql
The library used to build a chema and to execute queries on that schema.
Demos:
app1.js:
Stand-alone Apollo GraphQL Server
$ nodemon app1.js
$ open localhost:4000/using the GraphQL Playground:
{
books {
title
author
}
}app2.js
Apollo integrated with Express
const server = new ApolloServer({ typeDefs, resolvers})
const app = express()
server.applyMiddleware({app})app3.js
Rest API call from https://fourtonfish.com/
app4.js
Automatic Persisted Queries apollo-server-cache-memcached
- CDN Integration
Apollo Server works well with a Content-Distribution Network to cache full GraphQL query results. Apollo Server provides cache-control headers that a CDN uses to determine how long a request should be cached. For subsequent requests, the result will be served directly from the CDN’s cache. A CDN paired with Apollo Server’s persisted queries is especially powerful, since GraphQL operations can be shortened and sent with a HTTP GET request. To enable caching and a CDN in Apollo Server, follow the Performance Guide.
