How to use different scalar types for one field in graphQL schema?

799 views Asked by At

I have an input type that says:

input testInput {
a: String 
b: String
c: Boolean
}

I have a situation where field c can be either String or Boolean. How can i implement the field c that will accept both String and Boolean ?

1

There are 1 answers

0
rajesh On

Graphql does not support union of scalar types. So you can modify it this way

input testInput { a: String b: String c: hybridType }

type cBoolean { content: Boolean }

type cString { content: String }

union hybridType = cBoolean | cString