Created
August 16, 2022 16:48
-
-
Save Maxim-Filimonov/2160a24ade1073786540559441fe01e4 to your computer and use it in GitHub Desktop.
ApolloGraphQLInteraction with Pact V3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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