I am currently learning GraphQL and I have stumbled upon this error. How can I fix it while still using the GraphQLEnumType object.
const { ApolloServer, gql } = require('apollo-server');
const { GraphQLEnumType } = require('graphql');
const Bonus = new GraphQLEnumType({
name: 'Bonus',
values: {
BIG: {
value: "Big",
},
SMALL: {
value: "Small",
}
},
});
const typeDefs = gql`
enum Bonus {
BIG
SMALL
}
`;
const resolvers = {
Bonus : Bonus
}
const server = new ApolloServer({
typeDefs,
resolvers
});
server.listen().then(({ url }) => {
console.log(`???? Server ready at ${url}`);
});
Following is the error:
/home/jonas/Projects/javascript-questions-flow4b/backend/node_modules/graphql-tools/dist/generate/addResolveFunctionsToSchema.js:53 throw new _1.SchemaError(typeName + "." + fieldName + " was defined in resolvers, but enum is not in schema"); ^
Error: Bonus.name was defined in resolvers, but enum is not in schema