|
7 | 7 | <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> |
8 | 8 | **Table of Contents** |
9 | 9 |
|
10 | | -- [GraphQL and Graph*i*QL Spring Framework Boot Starters](#graphql-and-graphiql-spring-framework-boot-starters) |
11 | 10 | - [WARNING: NoClassDefFoundError when using GraphQL Java Tools > 5.4.x](#warning-noclassdeffounderror-when-using-graphql-java-tools--54x) |
12 | 11 | - [Using Gradle](#using-gradle) |
13 | 12 | - [Using Maven](#using-maven) |
14 | 13 | - [Documentation](#documentation) |
15 | 14 | - [Requirements and Downloads](#requirements-and-downloads) |
16 | 15 | - [Enable GraphQL Servlet](#enable-graphql-servlet) |
17 | 16 | - [Enable Graph*i*QL](#enable-graphiql) |
| 17 | +- [Enable Altair](#enable-altair) |
| 18 | +- [Enable GraphQL Playground](#enable-graphql-playground) |
| 19 | + - [Basic settings](#basic-settings) |
| 20 | + - [CDN](#cdn) |
| 21 | + - [Custom static resources](#custom-static-resources) |
| 22 | + - [Customizing GraphQL Playground](#customizing-graphql-playground) |
| 23 | + - [Tabs](#tabs) |
18 | 24 | - [Supported GraphQL-Java Libraries](#supported-graphql-java-libraries) |
19 | 25 | - [GraphQL Java Tools](#graphql-java-tools) |
20 | 26 | - [Tracing and Metrics](#tracing-and-metrics) |
| 27 | + - [Usage](#usage) |
21 | 28 | - [Contributions](#contributions) |
22 | 29 | - [Licenses](#licenses) |
23 | 30 |
|
@@ -55,6 +62,7 @@ Repository contains: |
55 | 62 | * `graphql-spring-boot-starter` to turn your boot application into GraphQL server (see [graphql-java-servlet](https://github.com/graphql-java-kickstart/graphql-java-servlet)) |
56 | 63 | * `altair-spring-boot-starter`to embed `Altair` tool for schema introspection and query debugging (see [altair](https://github.com/imolorhe/altair)) |
57 | 64 | * `graphiql-spring-boot-starter`to embed `GraphiQL` tool for schema introspection and query debugging (see [graphiql](https://github.com/graphql/graphiql)) |
| 65 | +* `playground-spring-boot-starter`to embed `GraphQL Playground` tool for schema introspection and query debugging (see [GraphQL Playground](https://github.com/prisma/graphql-playground)) |
58 | 66 | * `voyager-spring-boot-starter`to embed `Voyager` tool for visually explore GraphQL APIs as an interactive graph (see [voyger](https://github.com/APIs-guru/graphql-voyager)) |
59 | 67 |
|
60 | 68 | # Requirements and Downloads |
@@ -251,6 +259,102 @@ to set the classpath resources that should be loaded. |
251 | 259 |
|
252 | 260 | Headers that are used when sending the Altair queries can be set by defining them in the `altair.headers` group. |
253 | 261 |
|
| 262 | +# Enable GraphQL Playground |
| 263 | + |
| 264 | +GraphQL Playground becomes accessible at root `/playground` (or as configured in `graphql.playground.mapping`) |
| 265 | +if `playground-spring-boot-starter` is added as a dependency to a boot application. |
| 266 | + |
| 267 | +It uses an embedded `GraphQL Playground React`, in accordance to the [official guide](https://github.com/prisma/graphql-playground#as-html-page), |
| 268 | +using the 'minimum HTML' approach. |
| 269 | + |
| 270 | +Available Spring Boot configuration parameters (either `application.yml` or `application.properties`): |
| 271 | + |
| 272 | +```yaml |
| 273 | +graphql.playground: |
| 274 | + mapping: /playground |
| 275 | + endpoint: /graphql |
| 276 | + subscriptionsEndpoint: /subscriptions |
| 277 | + staticFolder.basePath: my-playground-resources-folder |
| 278 | + enabled: true |
| 279 | + pageTitle: Playground |
| 280 | + cdn: |
| 281 | + enabled: false |
| 282 | + version: latest |
| 283 | + settings: |
| 284 | + editor.cursorShape: line |
| 285 | + editor.fontFamily: "'Source Code Pro', 'Consolas', 'Inconsolata', 'Droid Sans Mono', 'Monaco', monospace" |
| 286 | + editor.fontSize: 14 |
| 287 | + editor.reuseHeaders: true |
| 288 | + editor.theme: dark |
| 289 | + general.betaUpdates: false |
| 290 | + prettier.printWidth: 80 |
| 291 | + prettier.tabWidth: 2 |
| 292 | + prettier.useTabs: false |
| 293 | + request.credentials: omit |
| 294 | + schema.polling.enable: true |
| 295 | + schema.polling.endpointFilter: "*localhost*" |
| 296 | + schema.polling.interval: 2000 |
| 297 | + schema.disableComments: true |
| 298 | + tracing.hideTracingResponse: true |
| 299 | + headers: |
| 300 | + headerFor: AllTabs |
| 301 | + tabs: |
| 302 | + - name: Example Tab |
| 303 | + query: classpath:exampleQuery.graphql |
| 304 | + headers: |
| 305 | + SomeHeader: Some value |
| 306 | + variables: classpath:variables.json |
| 307 | + responses: |
| 308 | + - classpath:exampleResponse1.json |
| 309 | + - classpath:exampleResponse2.json |
| 310 | +``` |
| 311 | +## Basic settings |
| 312 | + |
| 313 | +`mapping`, `endpoint` and `subscriptionsEndpoint` will default to `/playground`, `/graphql` and `/subscriptions`, |
| 314 | +respectively. Note that these values may not be empty. |
| 315 | + |
| 316 | +`enabled` defaults to `true`, and therefor Playground will be available by default if the dependency is added to a |
| 317 | + Spring Boot Web Application project. |
| 318 | + |
| 319 | +`pageTitle` defaults to `Playground`. |
| 320 | + |
| 321 | +`headers` allows you to specify headers for the default tab. Note that if your are using Spring Security and CSRF is |
| 322 | +enabled CSRF, the CSRF token will be automatically added to the headers. These headers will also be added to all the tabs |
| 323 | +configured under the [Tabs](#tabs) section. If a header is defined both in this 'global' header list and the header list |
| 324 | +of the individual tabs, the 'local' version will be used for that tab. |
| 325 | + |
| 326 | +## CDN |
| 327 | + |
| 328 | +The currently bundled version is `1.7.20`, which is - as of writing this - the latest release of `GraphQL Playground React`. |
| 329 | +The CDN option uses `jsDelivr` CDN, if enabled. By default, it will load the latest available release. |
| 330 | +Available CDN versions can be found on the project's |
| 331 | +[jsDelivr page](https://www.jsdelivr.com/package/npm/graphql-playground-react). The CDN option is disabled by default. |
| 332 | + |
| 333 | +## Custom static resources |
| 334 | + |
| 335 | +You can also specify a custom local version of Playground by setting the base path for `Playground` resources in |
| 336 | +the `staticPath.base` property. Under this directory, you have to provide the following files: |
| 337 | + |
| 338 | +* `static/css/index.css` |
| 339 | +* `static/js/middleware.js` |
| 340 | +* `favicon.png` |
| 341 | +* `logo.png` |
| 342 | + |
| 343 | +This is identical to the directory structure of the CDN under the `build` subfolder (where these files can be found). |
| 344 | + |
| 345 | +## Customizing GraphQL Playground |
| 346 | + |
| 347 | +Further GraphQL Playground settings can be specified under the `settings` group, which are documented in the official |
| 348 | +[GraphQL Playground readme](https://github.com/prisma/graphql-playground#settings). Note that enum-like values are |
| 349 | +validated against the available options, and your application will not start if wrong settings are provided. Similarly |
| 350 | +there is some basic validation for integer values (they must be valid positive integers). |
| 351 | + |
| 352 | +## Tabs |
| 353 | + |
| 354 | +Optionally, you can specify tabs that will be present when the user first opens GraphQL Playground. You can configure the |
| 355 | +query, variables, headers and even supply sample responses. Note that `query`, `variables` and `responses` are expected |
| 356 | +to be resources of the appropriate format (GraphQL for `query`, JSON for `variables` and `responses`). |
| 357 | + |
254 | 358 | # Supported GraphQL-Java Libraries |
255 | 359 |
|
256 | 360 | The following libraries have auto-configuration classes for creating a `GraphQLSchema`. |
|
0 commit comments