Cross-issue with https://github.com/artsy/metaphysics/issues/836
Likely related to https://github.com/apollographql/graphql-tools/issues/501 - the comment from @freiksenet seems to be exactly the conclusion we came to
An enum like this:
const HomePageHeroUnitType = new GraphQLObjectType({
name: "HomePageHeroUnit",
fields: {
...GravityIDFields,
cached,
mode: {
type: new GraphQLEnumType({
name: "HomePageHeroUnitMode",
values: {
LEFT_DARK: {
value: "left white",
},
LEFT_LIGHT: {
value: "left black",
},
CENTERED_DARK: {
value: "center white",
},
CENTERED_LIGHT: {
value: "center black",
},
RIGHT_DARK: {
value: "right white",
},
RIGHT_LIGHT: {
value: "right black",
},
},
}),
resolve: ({ type, menu_color_class }) => {
return type.toLowerCase() + " " + menu_color_class.toLowerCase()
},
},
When accessed via a stitched schema gets these errors:
"errors": [
{
"message": "Expected a value of type \"HomePageHeroUnitMode\" but received: LEFT_DARK"
},
{
"message": "Expected a value of type \"HomePageHeroUnitMode\" but received: LEFT_LIGHT"
},
{
"message": "Expected a value of type \"HomePageHeroUnitMode\" but received: LEFT_DARK"
},
{
"message": "Expected a value of type \"HomePageHeroUnitMode\" but received: LEFT_DARK"
},
{
"message": "Expected a value of type \"HomePageHeroUnitMode\" but received: LEFT_LIGHT"
}
],
Where it expects the lower case value, but is given the upper case enum string.
Thanks!
+1 Happened to us too.
This is really happening, I seems like a bug, I caught this as well, but, has a tricky to you pass for this error. Try set your field enum values with the same name of your enum names, like:
import { GraphQLEnumType } from 'graphql';
export default new GraphQLEnumType({
name: 'IndicatorRegisterReportEnum',
values: {
FIRST: {
value: 'FIRST',
},
SECOND: {
value: 'SECOND',
},
},
});
For me this following approach is working good! It's a way to ignore this even to be fixed!
I have this problem with graphql-compose also. From this discussion https://github.com/graphql/graphql-js/issues/435 and digging it out I see that they use Object as the internal represented value of enums. Then mergeSchemas will replace the object with the string of name
Folded into #1306, fixed by #1307
Most helpful comment
+1 Happened to us too.