Answer the question
In order to leave comments, you need to log in
Mutation error?
I started studying the graphQl + node js bundle I
started writing a small Api I
wrote methods for reading, deleting, adding. But I ran into a problem on the update method.
import {
GraphQLNonNull,
GraphQLID,
GraphQLString
} from 'graphql';
import clubType from '../../types/club';
import ClubModel from '../../../models/club';
export default {
type: clubType,
args: {
id: {
name: 'id',
type: new GraphQLNonNull(GraphQLID)
},
name: {
type: new GraphQLNonNull(GraphQLString)
}
},
resolve(root, params) {
const updateClub = ClubModel.findByIdAndUpdate(params.id, {
$set: {
name: params.name
}
}, {
new: true
})
if (!updateClub) {
throw new Error('error update club')
}
return updateClub;
}
}
"message": "The type of Mutation.UpdateClub must be Output Type but got: undefined."
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question