Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Couldn't find Type of name Mutation in the GraphQL Schema. #84

Closed
FrancoHawx opened this issue Mar 26, 2019 · 1 comment
Closed

Comments

@FrancoHawx
Copy link

I'm having problems making queries and creating / updating / deleting things in django graphql through the graphql plugin of vuex orm.

From the interface provided by django to execute queries, I can perfectly use my mutations and consult any particular data or any collection of them.

The error I receive is the following:
error vuex

As far as I understand the plugin, this error is given in the schema constructor but i don't understand why.

I'm going to write an example of how I create an object called "TipoProducto" from the django interface:

mutation myMutation {
 createTipoProducto(input: {nombre:"Pizza", descripcion:"foobar"}) {
     tipoProducto {nombre, descripcion}
 	status
 }
 }

This code will return the object with its attributes and a status 200 if it was successful.

My model in vuex orm:

import { Model } from '@vuex-orm/core';
import Product from './Product'

export default class TipProd extends Model {
    static entity = "tipProds"

    static fields () {
        return {
            id: this.increment(),
            nombre: this.attr(''),
            descripcion: this.attr(''),

            producto: this.hasMany(Product, 'tipProd_id')
            }
        }
    }


This is the method I try to use to create a new object "TipoProducto":

    methods: {
             async register (tipProduct) {
                await TipProd.insert({
                    data: 
                        tipProduct         
                });
                const tipProd = TipProd.query().last()
                await tipProd.$mutate({ name: 'createTipoProducto' });
    }

where data: tipProducto are the attributes taken from a form

I can not find the way that vuex orm correctly structured the query to create an object. What am I doing wrong?

I have apollo dev tools installed but it does not register any query or any other operation since it fails before being made.
I am aware that some methods could fail if I do not respect the naming conventions for schema operations from Django but it is not the case, I am not even able to do a simple fetch

Sorry for the english and thanks.

@FrancoHawx
Copy link
Author

I had a silly mistake in my API, where I wrote Mutations instead of Mutation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant