oslabs-beta / GraphQL-Gate

A GraphQL rate limiting library with query complexity analysisfor Node.js
http://graphqlgate.io
MIT License
57 stars 2 forks source link

Undefined fieldWeight throws an error during complexity anlaysis #59

Closed shalarewicz closed 2 years ago

shalarewicz commented 2 years ago

If the fieldWeight is undefined during complexity analysis then an unhandled error is thrown. These errors should be handled in development environments to provide clarity on why the fieldWeight is undefined. Production environments should attempt to default to a logical complexity value.

evanmcneely commented 2 years ago

Reassess this after updates to code base in PR #66

shalarewicz commented 2 years ago

After the refactor in #66, this occurs if an invalid parentName is provided when obtaining a resolvedTypeName in the fieldNode function. Temporarily fixing this in work on #44 by throwing an error if the parentName doesn't exist on typeWeights either due to capitalization or an invalid query (the latter case should be caught during schema validation).

We'll need to decide on how to handle this in a production environment.