@ams-pro/apollo-plugin-dyco v0.0.1
About The Project
The plugin calculates a complexity based on the resolver runtime. The plugin measures the time it takes for a resolver to finish its execution. New requests estimate the runtime based on past executions and prevents the execution if the max complexity is exceeded. If there is no information for the request is available yet, the plugin tries to estimate based on the schema.
Getting started
Installation
npm install @ams-pro/apollo-plugin-dyco graphql
or
yarn add @ams-pro/apollo-plugin-dyco graphql
Usage
Initialize the Plugin
import { ComplexityExtension, ComplexityPlugin, MetricStore } from '@ams-pro/apollo-plugin-dyco'; const metricStore = new MetricStore(); const server = new ApolloServer({ resolvers: [...], typeDefs: [...], plugins: [ new ComplexityPlugin(options), ], extensions: [ () => new ComplexityExtension(metricStore) ], });
Configure the plugin | Option | Required | Default | Description | |----------|----------|---------|-------------| |store|Yes||The shared store used by the extension| |max|No|10000|The maximum allowed complexity| |logging|No|false|Enable logging of calculated complexity| |listMultiplier|No|5|Multiplier for estimating lists if no information is available yet |objectMultiplier|No|1.1|Multiplier for estimating objects if no information is available yet
Contributing
Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License.
4 years ago