mdbook-preprocessor-graphql-playground-0.1.2 is not a library.
mdbook-preprocessor-graphql-playground
A preprocessor for mdbook to add GraphQL playgrounds.
Demo
https://aschaeffer.github.io/mdbook-preprocessor-graphql-playground/
Usage
- Install
mdbook-preprocessor-graphql-playground
cargo install mdbook-preprocessor-graphql-playground
- Add to
book.toml
:[] = "mdbook-graphql-playground" = ["html"] [] [] = ["graphql-playground-react-middleware.js", "graphql-playground.js"] = ["graphql-playground.css"]
- 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/
- Create a query file
mkdir -p <book_dir>/queries/swapi nano <book_dir>/queries/swapi/all-planets.query.graphql
- Create a config file
mkdir <book_dir>/configs nano <book_dir>/configs/swapi.json
- 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
Use a config in the book
- Embed with the
graphql_playground
function - Specify the location of the config file with the
config
parameter
{{ graphql_playground(config="/configs/swapi.json") }}
Example
A full example can be found in this repository