MCPcopy Create free account
hub / github.com/subquery/subql / checkLimit

Function checkLimit

packages/query/src/graphql/plugins/QueryAliasLimitPlugin.ts:7–17  ·  view source on GitHub ↗
(document: DocumentNode, limit: number)

Source from the content-addressed store, hash-verified

5import {GraphQLSchema, GraphQLError, DocumentNode, visit} from 'graphql';
6
7function checkLimit(document: DocumentNode, limit: number): void {
8 let aliasCount = 0;
9 visit(document, {
10 Field(node) {
11 if (node.alias) {
12 aliasCount += 1;
13 if (aliasCount > limit) throw new GraphQLError('Alias limit exceeded');
14 }
15 },
16 });
17}
18
19export function queryAliasLimit(options: {schema: GraphQLSchema; limit?: number}): ApolloServerPlugin {
20 return {

Callers 1

didResolveOperationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected