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
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
The text was updated successfully, but these errors were encountered:
I want to have both the expected and actual query complexity/cost, like in the shopify api: https://shopify.dev/api/usage/rate-limits#requested-and-actual-cost.
The expected query cost is pretty easy with this library, an example using an ApolloServer plugin:
However, I'm having trouble calculating the actual query cost, here is my attempt so far:
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 responseThe text was updated successfully, but these errors were encountered: