@@ -26,15 +26,12 @@ import { dispatchInfoSchema } from '../jobs/publisher-job';
2626import initCache from '../cache/init' ;
2727import { getRequiredEnvString } from '../utils/helpers' ;
2828import ipRangeCheck from 'ip-range-check' ;
29- import {
30- createComplexityRule ,
31- fieldExtensionsEstimator ,
32- getComplexity ,
33- simpleEstimator ,
34- } from 'graphql-query-complexity' ;
29+ import { fieldExtensionsEstimator , getComplexity , simpleEstimator } from 'graphql-query-complexity' ;
30+ import { depthLimit } from '@graphile/depth-limit' ;
3531
3632// Maximum allowed complexity
3733const MAX_COMPLEXITY = 100 ;
34+ const MAX_DEPTH = 5 ;
3835
3936const typeDefs = readFileSync ( join ( __dirname , './config/schema.graphql' ) , 'utf-8' ) ;
4037
@@ -125,6 +122,17 @@ export async function useKadenaGraphqlServer() {
125122 typeDefs,
126123 resolvers,
127124 introspection : true ,
125+ validationRules : [
126+ depthLimit ( {
127+ maxDepth : 7 , // Reasonable depth for most queries
128+ maxListDepth : 5 , // Prevent deeply nested array queries
129+ maxSelfReferentialDepth : 2 , // Limit recursive queries
130+ maxIntrospectionDepth : 15 , // Limit introspection query depth
131+ maxIntrospectionListDepth : 8 , // Limit introspection array depth
132+ maxIntrospectionSelfReferentialDepth : 2 ,
133+ revealDetails : false , // Don't expose limits to clients
134+ } ) ,
135+ ] ,
128136 plugins : [
129137 validatePaginationParamsPlugin ,
130138 ApolloServerPluginDrainHttpServer ( { httpServer } ) ,
0 commit comments