Hi - does anyone have a simple example of using `G...
# pact-js
a
Hi - does anyone have a simple example of using
GraphQLInteraction
with PactV3? I'm struggling with how to use it in the following approach as I'm not sure PactV3 has an
addInteraction()
method:
Copy code
const provider = new PactV3(...);

describe('query', () => {
  beforeEach(() => {
    const graphqlQuery = new GraphQLInteraction()
      .uponReceiving('a query')
      .withQuery('...')
      .withVariables({})
      .withRequest({
        path: '/graphql',
        method: 'POST',
      })
      .willRespondWith({
        status: 200,
        headers: { ... },
        body: { ... }
      });

    return provider.addInteraction(graphqlQuery);  <-- IS THIS VALID?
  )};
)};
m
V3 doesn't have a graphql API at the moment
a
Thanks Matt
m
If you take a look at the current graphql interface you could see how it's done. It's a very simple facade
Or a PR into the v3.x.x branch would be great too
a
I'll take a look - thanks again.
👍 1
@Matt (pactflow.io / pact-js / pact-go) for the PactV3 class, would the correct approach here be to subclass that class with the additional Graphql dsl methods (e.g. withVariables()) - just want to make sure I understand the intention behind the new design.
m
I think for now that’s probably the best idea
👍 1