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

How to test GraphQL API using Postman

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

    View Slide

  2. Technology Evangelist
    Postman
    Yoichi Kawasaki
    @postman_japan
    @yokawasa

    View Slide

  3. All rights reserved by Postman Inc
    About Postman

    View Slide

  4. 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.

    View Slide

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

    View Slide

  6. Various request protocols
    MQTT
    is coming soon

    View Slide

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

    View Slide

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

    View Slide

  9. All rights reserved by Postman Inc
    Testing GraphQL
    using Postman

    View Slide

  10. 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

    View Slide

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

    View Slide

  12. 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

    View Slide

  13. 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

    View Slide

  14. 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

    View Slide

  15. 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

    View Slide

  16. 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)

    View Slide

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

    View Slide

  18. 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.

    View Slide

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

    View Slide