Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
How to implement field-level complexity in graphql code-first approach?

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?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda