@@ -980,3 +980,56 @@ t.test("it counts rate limited requests", async (t) => {
980980 } ,
981981 ] ) ;
982982} ) ;
983+
984+ t . test ( "it counts rate limited GraphQL fields" , async ( t ) => {
985+ const routes = new Routes ( 200 ) ;
986+ routes . addRoute ( getContext ( "POST" , "/graphql" ) ) ;
987+ routes . addGraphQLField ( "POST" , "/graphql" , "query" , "user" ) ;
988+
989+ routes . countGraphQLFieldRateLimited ( "POST" , "/graphql" , "query" , "user" ) ;
990+
991+ t . same ( routes . asArray ( ) , [
992+ {
993+ method : "POST" ,
994+ path : "/graphql" ,
995+ hits : 1 ,
996+ rateLimitedCount : 0 ,
997+ graphql : undefined ,
998+ apispec : { } ,
999+ graphQLSchema : undefined ,
1000+ } ,
1001+ {
1002+ method : "POST" ,
1003+ path : "/graphql" ,
1004+ hits : 1 ,
1005+ rateLimitedCount : 1 ,
1006+ graphql : { type : "query" , name : "user" } ,
1007+ apispec : { } ,
1008+ graphQLSchema : undefined ,
1009+ } ,
1010+ ] ) ;
1011+
1012+ routes . addGraphQLField ( "POST" , "/graphql" , "query" , "user" ) ;
1013+ routes . countGraphQLFieldRateLimited ( "POST" , "/graphql" , "query" , "user" ) ;
1014+
1015+ t . same ( routes . asArray ( ) , [
1016+ {
1017+ method : "POST" ,
1018+ path : "/graphql" ,
1019+ hits : 1 ,
1020+ rateLimitedCount : 0 ,
1021+ graphql : undefined ,
1022+ apispec : { } ,
1023+ graphQLSchema : undefined ,
1024+ } ,
1025+ {
1026+ method : "POST" ,
1027+ path : "/graphql" ,
1028+ hits : 2 ,
1029+ rateLimitedCount : 2 ,
1030+ graphql : { type : "query" , name : "user" } ,
1031+ apispec : { } ,
1032+ graphQLSchema : undefined ,
1033+ } ,
1034+ ] ) ;
1035+ } ) ;
0 commit comments