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.
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.
same issue. I post a question at stackoverflow.
https://stackoverflow.com/questions/49939464/graphql-tools-how-can-i-use-mockserver-to-mock-a-mutation
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 鉁岋笍
Most helpful comment
wow was it so hard to just answer to wrap the query like this?
help your bros out guys 鉁岋笍