项目作者: wjsc

项目描述 :
Tiny in-memory persisted queries middleware for apollo-server-restify
高级语言: JavaScript
项目地址: git://github.com/wjsc/apollo-server-restify-persisted-queries.git
创建时间: 2018-10-27T23:34:47Z
项目社区:https://github.com/wjsc/apollo-server-restify-persisted-queries

开源协议:MIT License

下载


Current Version
NPM Minified size
Github Code Size
Downloads/Year
Issues
License
Contributors

NPM

apollo-server-restify-persisted-queries

Tiny in-memory automatic persisted queries middleware for apollo-server-restify

Since apollo-server-restify uses Apollo Server 1.x, it has not support for APQ.
Use this module to get server support.

This package implements a circular buffer that persists the latest X queries in a in-memory Map.

Usage

  1. import restify from 'restify';
  2. import { graphqlRestify } from 'apollo-server-restify';
  3. // 1. Import the module
  4. import { persistedQueries } from 'apollo-server-restify-persisted-queries';
  5. // 2. Set the number of cached queries
  6. const cacheLength = 10;
  7. const server = restify.createServer({
  8. title: 'Apollo Server',
  9. });
  10. const graphQLOptions = { schema: myGraphQLSchema };
  11. server.use(restify.plugins.bodyParser());
  12. server.use(restify.plugins.queryParser());
  13. // 3. Call the persistedQueries method, ant it returns a Middleware
  14. server.get('/graphql', persistedQueries(graphqlRestify(graphQLOptions)), cacheLength);
  15. server.listen(3000, () => console.log(`Listening on port 3000`));

Official Docs

https://www.apollographql.com/docs/guides/performance.html#automatic-persisted-queries