官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 夹江县| 天津市| 延川县| 蚌埠市| 包头市| 湄潭县| 安顺市| 昆明市| 乌兰县| 江孜县| 玛多县| 桑日县| 阳江市| 巴青县| 安康市| 长寿区| 宁陵县| 黎川县| 余姚市| 阳春市| 出国| 蓝田县| 昔阳县| 岳阳市| 广东省| 吉木萨尔县| 博湖县| 平和县| 城步| 合川市| 巧家县| 红安县| 嘉兴市| 南和县| 石屏县| 东明县| 武鸣县| 栾川县| 土默特右旗| 鹤岗市| 库车县|