-
Couldn't load subscription status.
- Fork 2k
Description
My feature request is partially related to #1627. Generally, I want to integrate with a graphql-query-complexity library that creates validationRules but it need access to the query variables values and they're not present in ValidationContext in graphql-js. Here's how it's configured using plain express-graphql middleware:
import queryComplexity from 'graphql-query-complexity';
import express from 'express';
import graphqlHTTP from 'express-graphql';
import schema from './schema';
const app = express();
app.use('/api', graphqlHTTP(async (request, response, {variables}) => ({
schema,
validationRules: [ queryComplexity({
maximumComplexity: 1000,
variables,
onComplete: (complexity: number) => {console.log('Query Complexity:', complexity);},
}) ]
})));In graphql-yoga there is a callback, like in apollo-server for context:
https://github.com/prisma/graphql-yoga/blob/3362b13374190fd2390594495dc08064e5ee4815/src/types.ts#L64-L77
And I think that apollo-server should support this kind of configuration too 😉 Changing ValidationContext mechanism in graphql-js is much more complicated and the only way that the author has figured out is by making validationRules dynamic in Apollo Server:
slicknode/graphql-query-complexity#7 (comment)