I want to define a mutation using graphql.
My mutation is getting an object as argument. So I defined the new Object in the schema and in the resolver using GraphQLObjec
Extra data (Related to the error - not to the Q code).
We define our resolvers in a map, where the map's keys correspond to our schema's types. https://www.apollographql.com/docs/tutorial/resolvers/
The most basic "hello world" example of this "wrong map" error.
I was wrong on purpose (under resolver definitions - use hello2
instead of hello
).
graphql-yoga server example:
/*index.js*/
const { GraphQLServer } = require('graphql-yoga')
const typeDefs = `
type Query {
hello(name: String): String!
}
`
const resolvers = {
Query: {
hello2: (_, { name }) => `Hello ${name || 'World'}`,
},
}
const server = new GraphQLServer({ typeDefs, resolvers })
server.start(() => console.log('Server is running on localhost:4000'))
Throw error:
[Error: Query.hello2 defined in resolvers, but not in schema]
Change the resolver to hello
(match to hello
schema type) to fix this error:
Related: