You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature request: adding path to estimators args(for calculating actual query complexity) #82
However, I'm having trouble calculating the actual query cost, here is my attempt so far:
{requestDidStart: async()=>({asyncwillSendResponse({ request, document, response }){// uses response objects to determine the actual operation complexityconstresponseEstimator: ComplexityEstimator=(options)=>{// there is no "options.path"// const object = _.get(response, options.path);// i can then use object.length(or something else) to get the number of returned items// return object.length ?? 1;return1;};constcomplexity=getComplexity({
schema,operationName: request.operationName,query: document!,variables: request.variables,estimators: [responseEstimator],});logger.info('Actual query complexity points:',{ complexity });},})}
It seems for this implementation to work I'd need access to the path of the field, like in https://github.com/graphql/graphql-js/blob/main/src/type/definition.ts#L896 or the fourth field on the resolvers(info.path), so I can map the field in which the complexity is being calculated to the actual response
Activity