Graphql-tools: Allow mockServer to mock mutations

Created on 14 Feb 2017  路  5Comments  路  Source: ardatan/graphql-tools

Hello !

I'm successfully using mockServer to test my queries, but now I need to test my mutations.
I found this, confirming this is possible but I can't find a proper way to implement it (Source)

My attempts :

this.mockServer.query(`
    mutation updateItem (id: 1, title: "Test") {
        id, title, price
    }
`).then(....)

... gives ...
GraphQLError: Cannot query field "mutation" on type "Query"

this.mockServer.mutation(`
    updateItem (id: 1, title: "Test") {
        id, title, price
    }
`).then(....)

...gives...
GraphQLError: this.mockServer.mutation is not a function

this.mockServer.query(`
    updateItem (id: 1, title: "Test") {
        id, title, price
    }
`).then(....)

...gives...
GraphQLError: Cannot query field "updateItem" on type "Query"

None of them worked.
Outside of the mock server context, my mutation works perfectly.

Thanks in advance for your help.

Most helpful comment

wow was it so hard to just answer to wrap the query like this?

this.mockServer.query(`mutation {
  updateItem (id: 1, title: "Test") {
    id, title, price
  }
}`);

help your bros out guys 鉁岋笍

All 5 comments

I think you might be misunderstanding GraphQL - try copying a mutation example from GraphQL.org.

@stubailo Care to explain?
Because I too am a bit lost and don't see the problem going on here, for it seems to be a proper usage of the mockServer from graphql-tools

I think this would be a better question for stackoverflow, since it isn't an issue with the library per se.

wow was it so hard to just answer to wrap the query like this?

this.mockServer.query(`mutation {
  updateItem (id: 1, title: "Test") {
    id, title, price
  }
}`);

help your bros out guys 鉁岋笍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MehrdadKhnzd picture MehrdadKhnzd  路  3Comments

udisun picture udisun  路  3Comments

brennantaylor picture brennantaylor  路  4Comments

stubailo picture stubailo  路  3Comments

confuser picture confuser  路  4Comments