pact-foundation / pact-js

JS version of Pact. Pact is a contract testing framework for HTTP APIs and non-HTTP asynchronous messaging systems.
https://pact.io
Other
1.59k stars 343 forks source link

Add GraphQL to V3 and V4 types #1093

Open mefellows opened 1 year ago

mefellows commented 1 year ago

See https://pact.canny.io/feature-requests/p/v3-support-for-graphql-interactions, and for some code snippets that could be pulled into the change.

Given how simple the code is (wrapper for the interaction type), I'm currently wary of adding it into the core code base and would like to consider the implications of doing so over a little further.

TimothyJones commented 1 year ago

My view is that adding it in is a strict improvement, as it makes the Pact-JS API consistent - where there's no difference between the V2 and V3/4 feature set.

My longer-term view is: for feature-parity with other languages, either neither graphql function should be in pact-js, OR the graphql wrapper should be in all the languages.

mefellows commented 12 months ago

Gist of how to do this here: https://gist.github.com/wabrit/2d1e1f9520aa133908f0a3716338e5ff

JJ-Kamminga commented 7 months ago

Is this still on the roadmap? I'm currently looking into using Pact for my team. We use almost exclusively GraphQL, and at the moment it is a bit messy to get it to work. I would like to use V3, but a lot of the examples (TypeScript example, blog post about GraphQL in Pact) are about Pact (pre-V3). But the rest of the docs are about V3, so it doesn't seem that pre-V3 is generally encouraged/supported...

mefellows commented 7 months ago

It's just sugar on top of the HTTP API, so you don't need the graphql interface to achieve GraphQL Testing. We would happily accept a PR though.

This being said, it's generally safe to use the pre-V3 interface in this scenario.

canny[bot] commented 1 week ago

This issue has been linked to a Canny post: V3 support for GraphQL interactions :tada:

YOU54F commented 1 week ago

See https://github.com/pact-foundation/roadmap/issues/94 for a feature request to build a native GraphQL plugin using the pact plugin framework, which would be probably be the preferred approach as it would allow other pact libraries to benefit, rather than the syntactic sugar that the graphql interface pact-js provided