A
A
Aleksandr2018-07-06 18:57:22
JavaScript
Aleksandr, 2018-07-06 18:57:22

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;
    }
}

The mistake itself
"message": "The type of Mutation.UpdateClub must be Output Type but got: undefined."

Link to turnip

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kiryushka Tsisar, 2018-07-06
@Sashjkeee

import { clubType } from '../../types/club';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question