Crates.io | mdbook-preprocessor-graphql-playground |
lib.rs | mdbook-preprocessor-graphql-playground |
version | 0.1.5 |
source | src |
created_at | 2022-09-10 15:38:26.908735 |
updated_at | 2024-10-26 13:35:58.541379 |
description | A preprocessor for mdbook to add GraphQL playgrounds. |
homepage | |
repository | https://github.com/aschaeffer/mdbook-preprocessor-graphql-playground |
max_upload_size | |
id | 662570 |
size | 6,539,490 |
A preprocessor for mdbook to add a GraphQL playground.
https://aschaeffer.github.io/mdbook-preprocessor-graphql-playground/
mdbook-preprocessor-graphql-playground
cargo install mdbook-preprocessor-graphql-playground
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"]
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/
mkdir -p <book_dir>/queries/swapi
nano <book_dir>/queries/swapi/all-planets.query.graphql
mkdir <book_dir>/configs
nano <book_dir>/configs/swapi.json
{{ graphql_playground(config="/configs/swapi.json") }}
query AllPlanetsQuery {
allPlanets {
planets {
name
diameter
}
}
}
{
"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"
}
]
}
graphql_playground
functionconfig
parameter{{ graphql_playground(config="/configs/swapi.json") }}
A full example can be found in this repository