|
| 1 | +--- |
| 2 | +date: 2021-05-17T07:00:00-05:00 |
| 3 | +title: Embedded Editors |
| 4 | +weight: 100 |
| 5 | +tags: |
| 6 | + [ |
| 7 | + "tooling", |
| 8 | + "embedded", |
| 9 | + "editors", |
| 10 | + "altair", |
| 11 | + "graphiql", |
| 12 | + "voyager", |
| 13 | + "playground", |
| 14 | + ] |
| 15 | +menu: |
| 16 | + main: |
| 17 | + identifier: boot-embedded-editors |
| 18 | + parent: Spring Boot |
| 19 | + url: /spring-boot/embedded-editors/ |
| 20 | +--- |
| 21 | + |
| 22 | +The following GraphQL Embedded Editors are bundled for convenience: |
| 23 | + |
| 24 | +- [Altair](#altair) |
| 25 | + - [Configuration Parameters](#configuration-parameters) |
| 26 | +- [GraphQL Playground](#graphql-playground) |
| 27 | + - [Configuration Parameters](#configuration-parameters-1) |
| 28 | +- [GraphiQL](#graphiql) |
| 29 | + - [Configuration Parameters](#configuration-parameters-2) |
| 30 | +- [GraphQL Voyager](#graphql-voyager) |
| 31 | + - [Configuration Parameters](#configuration-parameters-3) |
| 32 | + |
| 33 | +## Altair |
| 34 | + |
| 35 | +[Altair](https://github.com/imolorhe/altair) becomes accessible at the root /altair if the graphql.altair.enabled property is true. |
| 36 | + |
| 37 | +Note that GraphQL server must be available at /graphql/\* context to be discovered by Altair. |
| 38 | + |
| 39 | +### Configuration Parameters |
| 40 | + |
| 41 | +Available Spring Boot configuration parameters (either application.yml or application.properties): |
| 42 | + |
| 43 | +```yaml |
| 44 | +altair: |
| 45 | + enabled: true |
| 46 | + mapping: /altair |
| 47 | + subscriptions: |
| 48 | + timeout: 30 |
| 49 | + reconnect: false |
| 50 | + static: |
| 51 | + base-path: / |
| 52 | + page-title: Altair |
| 53 | + cdn: |
| 54 | + enabled: false |
| 55 | + version: 4.0.2 |
| 56 | + options: |
| 57 | + endpoint-url: /graphql |
| 58 | + subscriptions-endpoint: /subscriptions |
| 59 | + initial-settings: |
| 60 | + theme: dracula |
| 61 | + initial-headers: |
| 62 | + Authorization: "Bearer <your-token>" |
| 63 | + resources: |
| 64 | + initial-query: defaultQuery.graphql |
| 65 | + initial-variables: variables.graphql |
| 66 | + initial-pre-request-script: pre-request.graphql |
| 67 | + initial-post-request-script: post-request.graphql |
| 68 | +``` |
| 69 | +
|
| 70 | +## GraphQL Playground |
| 71 | +
|
| 72 | +[GraphQL Playground](https://github.com/prisma/graphql-playground) becomes accessible at root /playground (or as configured in graphql.playground.mapping) if the graphql.playground.enabled property is true. |
| 73 | +
|
| 74 | +It uses an embedded GraphQL Playground React, in accordance to the official guide, using the 'minimum HTML' approach. |
| 75 | +
|
| 76 | +### Configuration Parameters |
| 77 | +
|
| 78 | +Available Spring Boot configuration parameters (either application.yml or application.properties): |
| 79 | +
|
| 80 | +```yaml |
| 81 | +graphql.playground: |
| 82 | + mapping: /playground |
| 83 | + endpoint: /graphql |
| 84 | + subscriptionEndpoint: /subscriptions |
| 85 | + staticPath.base: my-playground-resources-folder |
| 86 | + enabled: true |
| 87 | + pageTitle: Playground |
| 88 | + cdn: |
| 89 | + enabled: false |
| 90 | + version: latest |
| 91 | + settings: |
| 92 | + editor.cursorShape: line |
| 93 | + editor.fontFamily: "'Source Code Pro', 'Consolas', 'Inconsolata', 'Droid Sans Mono', 'Monaco', monospace" |
| 94 | + editor.fontSize: 14 |
| 95 | + editor.reuseHeaders: true |
| 96 | + editor.theme: dark |
| 97 | + general.betaUpdates: false |
| 98 | + prettier.printWidth: 80 |
| 99 | + prettier.tabWidth: 2 |
| 100 | + prettier.useTabs: false |
| 101 | + request.credentials: omit |
| 102 | + schema.polling.enable: true |
| 103 | + schema.polling.endpointFilter: "*localhost*" |
| 104 | + schema.polling.interval: 2000 |
| 105 | + schema.disableComments: true |
| 106 | + tracing.hideTracingResponse: true |
| 107 | + headers: |
| 108 | + headerFor: AllTabs |
| 109 | + tabs: |
| 110 | + - name: Example Tab |
| 111 | + query: classpath:exampleQuery.graphql |
| 112 | + headers: |
| 113 | + SomeHeader: Some value |
| 114 | + variables: classpath:variables.json |
| 115 | + responses: |
| 116 | + - classpath:exampleResponse1.json |
| 117 | + - classpath:exampleResponse2.json |
| 118 | +``` |
| 119 | +
|
| 120 | +## GraphiQL |
| 121 | +
|
| 122 | +[GraphiQL](https://github.com/graphql/graphiql) becomes accessible at the root `/graphiql` if `graphiql.enabled` application property is set to `true`. |
| 123 | + |
| 124 | +Note that GraphQL server must be available at `/graphql/*` context to be discovered by Graph*i*QL. |
| 125 | + |
| 126 | +### Configuration Parameters |
| 127 | + |
| 128 | +Available Spring Boot configuration parameters (either `application.yml` |
| 129 | +or `application.properties`): |
| 130 | + |
| 131 | +```yaml |
| 132 | +graphiql: |
| 133 | + mapping: /graphiql |
| 134 | + endpoint: |
| 135 | + graphql: /graphql |
| 136 | + subscriptions: /subscriptions |
| 137 | + subscriptions: |
| 138 | + timeout: 30 |
| 139 | + reconnect: false |
| 140 | + basePath: / |
| 141 | + enabled: true |
| 142 | + pageTitle: GraphiQL |
| 143 | + cdn: |
| 144 | + enabled: false |
| 145 | + version: latest |
| 146 | + props: |
| 147 | + resources: |
| 148 | + query: query.graphql |
| 149 | + defaultQuery: defaultQuery.graphql |
| 150 | + variables: variables.graphql |
| 151 | + variables: |
| 152 | + editorTheme: "solarized light" |
| 153 | + headers: |
| 154 | + Authorization: "Bearer <your-token>" |
| 155 | +``` |
| 156 | + |
| 157 | +By default GraphiQL is served from within the package. This can be configured to be served from CDN |
| 158 | +instead, by setting the property `graphiql.cdn.enabled` to `true`. |
| 159 | + |
| 160 | +You are able to set the GraphiQL props as well. The `graphiql.props.variables` group can contain any |
| 161 | +of the props as defined at [GraphiQL Usage](https://github.com/graphql/graphiql#usage). Since |
| 162 | +setting (large) queries in the properties like this isn't very readable, you can use the properties |
| 163 | +in the `graphiql.props.resources` group to set the classpath resources that should be loaded. |
| 164 | + |
| 165 | +Headers that are used when sending the GraphiQL queries can be set by defining them in |
| 166 | +the `graphiql.headers` group. |
| 167 | + |
| 168 | +## GraphQL Voyager |
| 169 | + |
| 170 | +[GraphQL Voyager](https://github.com/APIs-guru/graphql-voyager) becomes accessible at root /voyager (or as configured in voyager.mapping) if the graphql.voyager.enabled property is true. |
| 171 | + |
| 172 | +Available Spring Boot configuration parameters (either application.yml or application.properties): |
| 173 | + |
| 174 | +### Configuration Parameters |
| 175 | + |
| 176 | +Available Spring Boot configuration parameters (either `application.yml` or `application.properties`): |
| 177 | + |
| 178 | +```yaml |
| 179 | +voyager: |
| 180 | + enabled: true |
| 181 | + basePath: / |
| 182 | + mapping: /voyager |
| 183 | + endpoint: /graphql |
| 184 | + cdn: |
| 185 | + enabled: false |
| 186 | + version: latest |
| 187 | + pageTitle: Voyager |
| 188 | + displayOptions: |
| 189 | + skipRelay: true |
| 190 | + skipDeprecated: true |
| 191 | + rootType: Query |
| 192 | + sortByAlphabet: false |
| 193 | + showLeafFields: true |
| 194 | + hideRoot: false |
| 195 | + hideDocs: false |
| 196 | + hideSettings: false |
| 197 | +``` |
0 commit comments