Debugging with Postman

Some time ago, Postman started as a Chrome app, which was installed through the Chrome Web Store.

Since Chrome apps will be deprecated, the guys behind Postman switched to a native implementation.

You can install Postman by downloading the appropriate file from the download section at, https://www.getpostman.com/apps.

There are numerous other HTTP client tools, such as Postman, that are useful for debugging your application. You are free to use your tool of choice. Some other great clients that I personally use are Insomnia, SoapUI, and Stoplight, but there are many more. In this book, we use Postman, as it is the most popular from my point of view.

When you have finished the installation, it should look something like this:

As you can see, I have already created a collection called Book in the left-hand panel. This collection includes our two requests: one to request all posts and one to add a new post.

As an example, the following screenshot shows you how the Add Post mutation looks in Postman:

The request body looks pretty much like what we saw before.

In my case, I need to write the query inline because Postman is not able to handle multi-row text inside JSON. If this is not the case for you, please ignore it.

Be sure to select application/json as Content-Type next to the raw format.

The URL is localhost, including port 8000 as expected.

If you add a new request, you can use the Ctrl + S shortcut to save it. You need to select a collection and a name to save it. One major downfall of using Postman (at least with GraphQL APIs) is that we are, of course, only using POST. It would be great to have some kind of indication of what we are doing here, for example, a query or a mutation. We will also see how to use authorization in Postman when we have implemented it.

Postman also has other great features, such as automated testing, monitoring, and mocking a fake server.

In later chapters, it will become more complicated to configure Postman for all requests. In such cases, I like to use Apollo Client Developer Tools, which perfectly integrate into the front end and make use of Chrome DevTools. What's great about Apollo Client Developer Tools is that they use Apollo Client we configure in the front end code and therefore reuse the authentication we built into our front end.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.37.68