Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to test GraphQL API using Postman

Yoichi Kawasaki
September 13, 2023

How to test GraphQL API using Postman

Presentation Slides for GraphQL Tokyo #21
Session title: How to test GraphQL API using Postman
Date: 2023/09/13

Yoichi Kawasaki

September 13, 2023
Tweet

More Decks by Yoichi Kawasaki

Other Decks in Technology

Transcript

  1. All rights reserved by Postman Inc How to test GraphQL

    API using Postman Yoichi Kawasaki Postman Presentation slides for GraphQL Tokyo #21
  2. 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.
  3. Many options to use Postman Postman Desktop App Postman Web

    Postman VS Code Extension Postman CLI
  4. Powering the Full API Lifecycle Producer Lifecycle Consumer Lifecycle Deploy

    Observe Distribute Define Design Develop Test Secure Evaluate Integrate Test Deploy Observe Discover
  5. 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
  6. 2 ways to test GraphQL with Postman You can test

    GraphQL with Postman in two ways: Postman GraphQL Client Postman HTTP request interface
  7. 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
  8. 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
  9. 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
  10. 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
  11. 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)
  12. Tests execution and results Write 7 tests in the Test

    stage execute Outputs the results of each test
  13. 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.