Open kapouer opened 8 years ago
graphql equivalent of oneOf is more explicit about how to choose the right schema, but i think oneOf
is implementable using something like
const isValidJSValue = require('graphql/src/utilities').isValidJSValue;
var PetType = new GraphQLUnionType({
name: 'Pet',
types: [ DogType, CatType ],
resolveType(value) {
return [ DogType, CatType ].find(function(type) {
return isValidJSValue(type, value);
});
}
});
There might be an issue with the type when it is GraphQLObjectType, since isValidJSValue expects Input types.
Something like http://stackoverflow.com/a/25033301/4312202 gives
TestPropertiesEnum values must be an object with value names as keys.
(This is a reference for future PR - i know you're busy).