Enums fail to resolve correctly with a value of 0, when using Federation.
Versions:
"@apollo/federation": "^0.9.4",
"apollo-server": "^2.9.3",
"graphql": "^14.1.1",
"graphql-tools": "^4.0.4"
Example Repo:
https://github.com/postman-nz/gql-federation-issue
Server Code:
const { ApolloServer, gql } = require("apollo-server");
const { buildFederatedSchema } = require("@apollo/federation");
const typeDefs = gql`
type Query {
colorBad: AllowedColor
colorGood: AllowedColor
}
enum AllowedColor {
RED
GREEN
BLUE
}
`;
const resolvers = {
Query: {
colorBad: () => 0,
colorGood: () => 1
},
AllowedColor: {
RED: 0,
GREEN: 1,
BLUE: 2
}
};
// Works with this server
/*
const server = new ApolloServer({
typeDefs,
resolvers
});
*/
const server = new ApolloServer({
schema: buildFederatedSchema({
typeDefs,
resolvers
})
});
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
Success when running the Query
We get the expected result.
{
"data": {
"colorGood": "GREEN"
}
}
Failure when running the query
An error is returned: "Expected a value of type \"AllowedColor\" but received: 0"
Expected Behavior:
{
"data": {
"colorBad": "RED"
}
}
If Federation is removed, both of the queries run as expected.
Enums fail to resolve correctly with a value of 0, when using Federation.
Versions:
Example Repo:
https://github.com/postman-nz/gql-federation-issue
Server Code:
Success when running the Query
We get the expected result.
Failure when running the query
An error is returned:
"Expected a value of type \"AllowedColor\" but received: 0"Expected Behavior:
If Federation is removed, both of the queries run as expected.