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?
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).
}
}