I ran into such a problem when dealing with query complexity in GraphQL. The package I used is graphql-query-complexity.
App.js:
app.use(
'/graphql',
graphqlHTTP((req) => ({
schema: schema,
graphiql: true,
validationRules: [
createComplexityRule({
estimators: [
simpleEstimator({ defaultComplexity: 1 }),
],
maximumComplexity: 20,
},
}),
]
}))
);
It works well, but when I looked at other examples on the internet, I saw that they use Field-level complexity there. That is, they can set a different complexity for each field. But can’t understand it because they use TypeGraphQL server, I use express-graphql
Example were:
@Field({ complexity: 3 })
title: string;
But my express-graphql code-first approach code:
const PostTypes: { comment: GraphQLObjectType } = {
post: new GraphQLObjectType({
name: 'Post',
fields: () => ({
title: { type: graphql.GraphQLString },
}),
}),
};
export default PostTypes;
So, how can I implement this for my structure?