Slide 1

Slide 1 text

All rights reserved by Postman Inc How to test GraphQL API using Postman Yoichi Kawasaki Postman Presentation slides for GraphQL Tokyo #21

Slide 2

Slide 2 text

Technology Evangelist Postman Yoichi Kawasaki @postman_japan @yokawasa

Slide 3

Slide 3 text

All rights reserved by Postman Inc About Postman

Slide 4

Slide 4 text

What is Postman? Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs—faster.

Slide 5

Slide 5 text

Many options to use Postman Postman Desktop App Postman Web Postman VS Code Extension Postman CLI

Slide 6

Slide 6 text

Various request protocols MQTT is coming soon

Slide 7

Slide 7 text

Powering the Full API Lifecycle Producer Lifecycle Consumer Lifecycle Deploy Observe Distribute Define Design Develop Test Secure Evaluate Integrate Test Deploy Observe Discover

Slide 8

Slide 8 text

Postman main components / features for API Testing Monitor MockServer Performance Test Collection Runner

Slide 9

Slide 9 text

All rights reserved by Postman Inc Testing GraphQL using Postman

Slide 10

Slide 10 text

You can test GraphQL using Postman query GetAllAlbums ($genre: Genre) { albums (genre: $genre) { title artist { name } tracks { title number } genre } } Artist Service Tracks Service Genre Service Aggregated Response Request

Slide 11

Slide 11 text

2 ways to test GraphQL with Postman You can test GraphQL with Postman in two ways: Postman GraphQL Client Postman HTTP request interface

Slide 12

Slide 12 text

Postman HTTP Request Interface Postman’s built-in HTTP request interface that also support for sending GraphQL queries in the request body, using GraphQL variables Using GraphQL with the HTTP request interface https://learning.postman.com/docs/sending-requests/graphql/graphql-http/ Query editor Automatic schema fetch GraphQL variables URL bar

Slide 13

Slide 13 text

Postman GraphQL Client more focus on GraphQL that help you debug and document your GraphQL API effectively and efficiently. Postman GraphQL Client Schema explorer Query editor Query variables You can also use the Query button dropdown to browse and select queries to execute Query buttonDropdown URL bar

Slide 14

Slide 14 text

Postman GraphQL client allows you to - Explore your schema easily and quickly - Automatically introspect or manually import your schema - Quickly build a query, mutation, or subscription to get the data Postman GraphQL Client

Slide 15

Slide 15 text

Introspection and manual importing GraphQL Schema To enable auto-completion and Query explorer, your request needs a GraphQL schema. Postman support GraphQL introspection and manual importing GraphQL schemas. Automatic fetch (introspection) Manual Import You can manually import GraphQL schema in APIs in the sidebar Postman will automatically fetch a schema based on the request URL, using GraphQL introspection

Slide 16

Slide 16 text

Use JavaScript code / scripts to write API tests You can add JavaScript code to execute during two events in the flow: Pre-request (Before Query) Test (After response) Request Response Scripts in Pre-request stage (Before Query) Scripts in Tests stage (After response)

Slide 17

Slide 17 text

Tests execution and results Write 7 tests in the Test stage execute Outputs the results of each test

Slide 18

Slide 18 text

Download and start for free! https://www.postman.com/downloads/ Desktop Application ● Windows ● Mac ● Linux Web Application ● You can also use the same functions in your browser by registering for an account.

Slide 19

Slide 19 text

Thank You! ご清聴いただき、ありがとうございました