Closed dkulezich closed 3 years ago
That error suggests that operationName
should be StationsQuery
but instead is not coming through at all.
That implies:
If the behaviour is correct, then you need to update your expected interaction to not expect your code to send that operation name. Otherwise, you've just found a bug.
Thank you for your answer, Matt. I've removed the operation name when setting the graphql interaction and from the query and I still get the same error as described above. This behaviour is observed only when using graphql-request package, if I execute the same code with apollo client package it runs without errors and the contract is generated.
Could you please attach the log file so we can see what's going on?
Sure, here are both logs with and without Operation name pact-noOperationName.log pact.log
Thanks. So the pact.log
file is the one failing, because as you say, it's expecting operationName
but is not receiving it. The pact-noOperationName.log
seems to be a working pact.
Can I assume that pact-noOperationName.log
is the one where you were still using the apollo client? The user-agent looks the same, so I'm a bit confused.
If you have a minute to chat in slack, i'll see you in #graphql, otherwise, I think I'm going to need to see your code to be able to help diagnose further.
Thanks, Mat, for your help. As you suggested I have removed the operationName
from the test (deleted .withOperation("StationsQuery")
) and added the headers: {}
property to the the response ( to .willRespondWith()
) and it did the job! Our tests are passing now and the contracts are successfully generated.
Sounds like this got sorted out, so I'll close it. Feel free to reopen if there are any changes required.
Software versions
Issue Checklist
Description
We switched from Apollo to graphql-request in our project. Since then we use graphqlClient to do the requests to the Pact Mock server. Once we did that our pact tests started failing. We didn't change anything else and the tests were passing before.
Expected behaviour
Pact tests pass successfully when using graphql-request package
Actual behaviour
Tests are failing
Steps to reproduce
Replace ApolloClient with GraphQLClient
Relevant log files