From 4066faaef123e1a143fad9e4013e65605861cbc9 Mon Sep 17 00:00:00 2001 From: carrolp Date: Mon, 11 Mar 2024 15:25:29 -0400 Subject: [PATCH] handle invalid queries (#1355) --- app/apollo/index.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/apollo/index.js b/app/apollo/index.js index d8c2f029..5de2c2b2 100644 --- a/app/apollo/index.js +++ b/app/apollo/index.js @@ -352,9 +352,14 @@ const apollo = async (options = {}) => { } } else { - const parsedQuery = parse( payload.query ); - for( let def of parsedQuery.definitions ) { - if( def.selectionSet && def.selectionSet.selections ) count += def.selectionSet.selections.length; + try { + const parsedQuery = parse( payload.query ); + for( let def of parsedQuery.definitions ) { + if( def.selectionSet && def.selectionSet.selections ) count += def.selectionSet.selections.length; + } + } + catch( e ) { + // invalid/unparsable GQL query, ignore (gql will handle faiure) } } return( count );