-
Notifications
You must be signed in to change notification settings - Fork 53
API Testing with Insomnia
alismx edited this page Dec 22, 2022
·
7 revisions
This page explains how to make requests to the GraphQL API using Insomnia.
- Install Insomnia
- Click the + dropdown
- Click "GraphQL Request"
- Update the endpoint to be whatever your backend URL is +
/graphql
- e.g., if running the backend on
http://localhost:8080
, it would behttp://localhost:8080/graphql
- if running the backend on
https://localhost.simplereport.gov/api
, it would behttps://localhost.simplereport.gov/api/graphql
- if trying to make a GraphQL request against production, it would be
https://www.simplereport.gov/api/graphql
- Click the "Header" tab
- Add a new header called
Content-Type
with a corresponding value ofapplication/json
- Add another new header called
Authorization
with a corresponding value ofBearer ${access_token}
(follow these steps to get the${access_token}
value) - Click on the "GraphQL" tab
- Ensure it is a "POST" request
- Paste the following query and ensure you get a 200 response:
query {
whoami {
id
}
}
- You are ready to make requests to the GraphQL API!
-
NOTE: You'll need to update the Bearer token periodically, as SimpleReport re-generates access tokens regularly for security purposes.
-
Load the simplereport app in a web browser
- The following will be instructions for a Chrome browser, but other browsers should be similar
-
Open the dev tools for your browser (CMD + shift + I, or right click -> "Inspect")
-
Follow steps 1 OR 2 below
1. via the "Console" tab
- Click the "Console" tab
- Run
localStorage.getItem("access_token")
- Copy the returned value without the beginning and ending quotes
2. via the "Application" tab
- Click the "Application" tab
- Click "Local Storage" and click the URL where the frontend is running
- Get the value of the key called
access_token
- If you see any errors saying it had issues loading the schema or something of that nature, try clicking the small
"schema" with a wrench button
and then click "Refresh Schema"
You may want to create "Environment Overrides" for your collection of requests, so you do not have to update the bearer token on each request manually. To do so, do the following:
- Right-click your collection of requests in the sidebar, and that should open a dropdown
- Click "Environment"
- That should open up a pop-up called "Environment Overrides (JSON Format)"
- Here you can add any variables, for example
{
"bearer": "[YOUR_TOKEN_HERE]"
}
- Now you can use the variable in your requests.
- Getting Started
- [Setup] Docker and docker compose development
- [Setup] IntelliJ run configurations
- [Setup] Running DB outside of Docker (optional)
- [Setup] Running nginx locally (optional)
- [Setup] Running outside of docker
- Accessing and testing weird parts of the app on local dev
- Accessing patient experience in local dev
- API Testing with Insomnia
- Cypress
- How to run e2e locally for development
- E2E tests
- Database maintenance
- MailHog
- Running tests
- SendGrid
- Setting up okta
- Sonar
- Storybook and Chromatic
- Twilio
- User roles
- Wiremock
- CSV Uploader
- Log local DB queries
- Code review and PR conventions
- SimpleReport Style Guide
- How to Review and Test Pull Requests for Dependabot
- How to Review and Test Pull Requests with Terraform Changes
- SimpleReport Deployment Process
- Adding a Developer
- Removing a developer
- Non-deterministic test tracker
- Alert Response - When You Know What is Wrong
- What to Do When You Have No Idea What is Wrong
- Main Branch Status
- Maintenance Mode
- Swapping Slots
- Monitoring
- Container Debugging
- Debugging the ReportStream Uploader
- Renew Azure Service Principal Credentials
- Releasing Changelog Locks
- Muting Alerts
- Architectural Decision Records
- Backend Stack Overview
- Frontend Overview
- Cloud Architecture
- Cloud Environments
- Database ERD
- External IDs
- GraphQL Flow
- Hibernate Lazy fetching and nested models
- Identity Verification (Experian)
- Spring Profile Management
- SR Result bulk uploader device validation logic
- Test Metadata and how we store it
- TestOrder vs TestEvent
- ReportStream Integration
- Feature Flag Setup
- FHIR Resources
- FHIR Conversions
- Okta E2E Integration
- Deploy Application Action
- Slack notifications for support escalations
- Creating a New Environment Within a Resource Group
- How to Add and Use Environment Variables in Azure
- Web Application Firewall (WAF) Troubleshooting and Maintenance
- How to Review and Test Pull Requests with Terraform Changes