5.6.0 (2019-01-31)
Features
- add UnionTypeComposer helper (880eecf)
The most useful method is addTypeResolver
– it helps to add a Type to Union and also provide a function which will verify compliance of js object to provided GraphQL type:
const utc = new UnionTypeComposer('MyUnion');
PersonTC = TypeComposer.create(`
type Person { age: Int, field1: String, field2: String }
`);
utc.addTypeResolver(PersonTC, value => {
return value.hasOwnProperty('age');
});
KindRedTC = TypeComposer.create(`
type KindRed { kind: String, field1: String, field2: String, red: String }
`);
utc.addTypeResolver(KindRedTC, value => {
return value.kind === 'red';
});