Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!