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

177
Visualizações
Accepting Int or String in graphQL schema

I have an input type in my apollo graphql schema, My schema looks like:

input Score {
    total: String! // The input we recieve from the user might be a string or an int.
    
  }

So, I want the total to be an string or int. How can I implement that? Should I use custom scalar types or is there any better way?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Well your Schema can be as it are!

typeDefs= gql`
input Score{
   total: String!
}

type mutation{
   totalBE: (input: Score)
}
`
Query:{
    totalBe: ScoreBe(_,param);

}

but in the back end function resoolver

resoolvers = {
ScoreBe(paramArgs):{
   score = paramArgs.input.total;
      //deal with it as String and Interger at the same time in your middleware or backEnd Technollogy. (is most easy here).

}
}

about 4 years ago · Juan Pablo Isaza Relatório
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