Is there a way for me to define an input / argtype that could either be a ContactCreate
or a ContactRead
? I'm uncertain if it's feasible.
import { ContactCreate } from 'contact/ContactCreate'
import { ContactRead } from 'contact/ContactRead'
import { ArgsType, createUnionType, Field } from 'type-graphql'
const ContactObtainUnion = createUnionType({
name: 'ContactObtain',
types: () => [ContactCreate, ContactRead],
resolveType: value => {
if ('uuid' in value) {
return ContactRead
}
return ContactCreate
}
})
@ArgsType()
export class ContactObtain {
@Field(() => ContactObtainUnion)
contact: typeof ContactObtainUnion
}
Would it be possible to use a union of two distinct type objects as a @Field
?