Skip to content

Instantly share code, notes, and snippets.

@Maxim-Filimonov
Created August 16, 2022 16:48
Show Gist options
  • Save Maxim-Filimonov/2160a24ade1073786540559441fe01e4 to your computer and use it in GitHub Desktop.
Save Maxim-Filimonov/2160a24ade1073786540559441fe01e4 to your computer and use it in GitHub Desktop.
ApolloGraphQLInteraction with Pact V3
function convertApolloToV3Interaction(
apolloInteraction: ApolloGraphQLInteraction,
states?: V3ProviderState[],
): V3Interaction {
const interaction = apolloInteraction.json();
return {
states,
uponReceiving: interaction.description,
withRequest: {
method: interaction.request.method,
path: interaction.request.path,
query: {}, // this is not used on gql interactions
body: interaction.request.body,
headers: interaction.request.headers,
},
willRespondWith: {
status: interaction.response.status,
body: interaction.response.body,
headers: interaction.response.headers,
},
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment