Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

145
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda