(document: DocumentNode, limit: number)
| 5 | import {GraphQLSchema, GraphQLError, DocumentNode, visit} from 'graphql'; |
| 6 | |
| 7 | function 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 | |
| 19 | export function queryAliasLimit(options: {schema: GraphQLSchema; limit?: number}): ApolloServerPlugin { |
| 20 | return { |
no outgoing calls
no test coverage detected