Skip to content

Djones-qa/graphql-api-testing

Repository files navigation

GraphQL API Testing

CI

GraphQL API testing framework using Playwright and TypeScript against the SpaceX public GraphQL API.

What is GraphQL?

GraphQL is a query language for APIs that allows clients to request exactly the data they need. Unlike REST APIs with multiple endpoints, GraphQL uses a single endpoint with flexible queries. Used by Facebook, GitHub, Twitter, and Shopify.

Tech Stack

  • Playwright APIRequestContext
  • TypeScript
  • GraphQL
  • SpaceX Public GraphQL API
  • GitHub Actions CI

Project Structure

graphql-api-testing/ ├── tests/ │ ├── launches.spec.ts # Launch query tests │ ├── rockets.spec.ts # Rocket query tests │ └── company.spec.ts # Company info tests ├── utils/ │ └── graphql.ts # GraphQL query helper ├── playwright.config.ts └── .github/workflows/ └── graphql-tests.yml

Test Coverage (12 tests)

Launches (5 tests)

  • Returns list of all launches
  • Each launch has required fields
  • Query with pagination limit
  • Upcoming launches returns array
  • Latest launch has required fields

Rockets (4 tests)

  • Returns list of all rockets
  • Each rocket has required schema fields
  • Query rockets with pagination
  • Fetch single rocket by ID

Company (3 tests)

  • Returns company info with required fields
  • Company name is SpaceX
  • Company founded year is 2002

GraphQL vs REST

`graphql

GraphQL — one endpoint, request only what you need

query { launches(limit: 5) { id mission_name launch_success } }

REST — multiple endpoints, get everything

GET /launches

GET /launches/:id

GET /rockets

`

Run Tests

�ash npm install npx playwright install chromium npm test # Run all tests npm run test:launches # Launches only npm run test:rockets # Rockets only npm run test:company # Company only

Author

Darrius Jones - github.com/Djones-qa

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors