How can I re-use my Tests for a GraphQL API on postman

I am currently creating tests for a GraphQL API using Postman and trying to figure out a way to re-use my tests and avoid copy-pasting the same thing over multiple queries and use cases.

We have tried making the common tests into functions which can then be called but although we can pack the pre-request stuff and the testing stuff into reusable functions the graphql query itself is still stuck in its own request…which STILL needs to be copy-pasted.

Any pointers on an efficient way to get this done?

Hi @marynel

Are you looking to create new tests that use the same, request model but with different parameters? For example you have a model like:

{
  "username" : "admin", 
  "password" : "password123" 
}

You want to update the fields “admin” and “password123” but keep the same structure?

Hi @marynel!

I’d like to help if I can (I did some GraphQL work in Postman in the past).
I’m a little unclear on what the problem is - are you able to give a bit of an example on what you might be copying / pasting into the requests?

Thanks!
James.