The Star Wars API

The Star Wars API, or "swapi" (Swah-pee) is the world's first quantified and programmatically-accessible data source for all the data from the Star Wars canon universe!

We've taken all the rich contextual stuff from the universe and formatted into something easier to consume with software. Then we went and stuck an API on the front so you can access it all!

The GraphQL Playground

Credits

PokeAPI

The PokeAPI is a full GraphQL API linked to an extensive database detailing everything about the Pokémon main game series. We've covered everything from Pokémon to Berry Flavors.

The GraphQL Playground

Why

Interactive Documentation: https://inexorgame.github.io/inexor-rgf-application/Plugins_Arithmetic.html

Usage

https://aschaeffer.github.io/mdbook-preprocessor-graphql-playground/

Usage

  1. Install mdbook-preprocessor-graphql-playground
    cargo install mdbook-preprocessor-graphql-playground
    
  2. Add to book.toml:
    [preprocessor.graphql-playground]
    command = "mdbook-graphql-playground"
    renderer = ["html"]
    
    [output]
    
    [output.html]
    additional-js = ["graphql-playground-react-middleware.js", "graphql-playground.js"]
    additional-css = ["graphql-playground.css"]
    
  3. Copy assets into the book root directory:
    cp assets/graphql-playground.css <book_dir>
    cp assets/graphql-playground.js <book_dir>
    cp assets/graphql-playground-react-middleware.js <book_dir>
    cp assets/images/* <book_dir>/src/images/
    
  4. Create a query file
    mkdir -p <book_dir>/queries/swapi
    nano <book_dir>/queries/swapi/all-planets.query.graphql
    
  5. Create a config file
    mkdir <book_dir>/configs
    nano <book_dir>/configs/swapi.json
    
  6. Embed the GraphQL Playground in your markdown files
    {{ graphql_playground(config="/configs/swapi.json") }}
    

Query files

  • You can have multiple queries
query AllPlanetsQuery {
  allPlanets {
    planets {
      name
      diameter
    }
  }
}

Config files

  • You can have multiple config files
  • You can have multiple tabs, each refers to a query
{
  "title": "The Star Wars API",
  "description": "Explore the star wars API using mdbook-preprocessor-graphql-playground",
  "endpoint": "https://swapi-graphql.netlify.app/.netlify/functions/index",
  "tabs": [
    {
      "name": "All Planets",
      "url": "/queries/swapi/all-planets.query.graphql"
    }
  ]
}

Use a config in the book

  1. Embed with the graphql_playground function
  2. Specify the location of the config file with the config parameter

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

Unreleased

[0.1.5] - 2024-10-26

Changed

  • CI: Improved workflows and improved security
  • CI: Upgraded GitHub Actions
  • CI: Added dependabot
  • CI: Automatically update dependencies and set wip progress
  • CI: Automatically publish new versions to GitHub Releases and crates.io

[0.1.4] - 2024-09-07

Changed

  • Upgraded dependencies

[0.1.3] - 2023-07-15

Fixed

  • Support variables and headers in tabs (https://github.com/graphql/graphql-playground/issues/1018)

[0.1.0] - 2022-09-10

Added

  • Initial release

MIT License

Copyright (c) 2022 Andreas Schaeffer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.