Skip to content

Commit

Permalink
handle invalid queries (#1355)
Browse files Browse the repository at this point in the history
  • Loading branch information
carrolp authored Mar 11, 2024
1 parent 5f66ee8 commit 4066faa
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/apollo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 4066faa

Please sign in to comment.