Skip to content

Commit ced58ea

Browse files
Raj K Singhhuv1k
authored andcommitted
* Merged from sdl-tabs https://github.com/Novvum/graphql-playground.git * Added and integrated setting's key for 'schema.disableComments' * Merged changes from disableComments branch * Fixes and style changes matching @kuldar's design specs. Details on #897 comments * Still not able to cmd+save settings. Might be a deeper issue. However, save button saves disabled comments * Added tabWidth prop to SideTab.tsx to provide specific widths for different tabs. * Fix for Tab Spacing in collapsed state Fix for additional line-breaks after each item
1 parent 740a66b commit ced58ea

File tree

26 files changed

+1679
-422
lines changed

26 files changed

+1679
-422
lines changed

README.md

Lines changed: 96 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,33 @@ $ brew cask install graphql-playground
1515

1616
## Features
1717

18-
* ✨ Context-aware autocompletion & error highlighting
19-
* 📚 Interactive, multi-column docs (keyboard support)
20-
* ⚡️ Supports real-time GraphQL Subscriptions
21-
* ⚙ GraphQL Config support with multiple Projects & Endpoints
22-
* 🚥 Apollo Tracing support
18+
- ✨ Context-aware autocompletion & error highlighting
19+
- 📚 Interactive, multi-column docs (keyboard support)
20+
- ⚡️ Supports real-time GraphQL Subscriptions
21+
- ⚙ GraphQL Config support with multiple Projects & Endpoints
22+
- 🚥 Apollo Tracing support
2323

2424
## FAQ
2525

2626
### How is this different from [GraphiQL](https://github.com/graphql/graphiql)?
2727

2828
GraphQL Playground uses components of GraphiQL under the hood but is meant as a more powerful GraphQL IDE enabling better (local) development workflows. Compared to GraphiQL, the GraphQL Playground ships with the following additional features:
2929

30-
* Interactive, multi-column schema documentation
31-
* Automatic schema reloading
32-
* Support for GraphQL Subscriptions
33-
* Query history
34-
* Configuration of HTTP headers
35-
* Tabs
30+
- Interactive, multi-column schema documentation
31+
- Automatic schema reloading
32+
- Support for GraphQL Subscriptions
33+
- Query history
34+
- Configuration of HTTP headers
35+
- Tabs
3636

3737
See the following question for more additonal features.
3838

3939
### What's the difference between the desktop app and the web version?
4040

4141
The desktop app is the same as the web version but includes these additional features:
4242

43-
* Partial support for [graphql-config](https://github.com/prismagraphql/graphql-config) enabling features like multi-environment setups (no support for sending HTTP headers).
44-
* Double click on `*.graphql` files.
43+
- Partial support for [graphql-config](https://github.com/prismagraphql/graphql-config) enabling features like multi-environment setups (no support for sending HTTP headers).
44+
- Double click on `*.graphql` files.
4545

4646
### How does GraphQL Bin work?
4747

@@ -77,43 +77,44 @@ These are the settings currently available:
7777

7878
The React component `<Playground />` and all middlewares expose the following options:
7979

80-
* `props` (Middlewares & React Component)
81-
* `endpoint` [`string`](optional) - the GraphQL endpoint url.
82-
* `subscriptionEndpoint` [`string`](optional) - the GraphQL subscriptions endpoint url.
83-
* `workspaceName` [`string`](optional) - in case you provide a GraphQL Config, you can name your workspace here
84-
* `config` [`string`](optional) - the JSON of a GraphQL Config. See an example [here](https://github.com/prismagraphql/graphql-playground/blob/master/packages/graphql-playground-react/src/localDevIndex.tsx#L47)
85-
* `settings` [`ISettings`](optional) - Editor settings in json format as [described here](https://github.com/prismagraphql/graphql-playground#settings)
80+
- `props` (Middlewares & React Component)
81+
- `endpoint` [`string`](optional) - the GraphQL endpoint url.
82+
- `subscriptionEndpoint` [`string`](optional) - the GraphQL subscriptions endpoint url.
83+
- `workspaceName` [`string`](optional) - in case you provide a GraphQL Config, you can name your workspace here
84+
- `config` [`string`](optional) - the JSON of a GraphQL Config. See an example [here](https://github.com/prismagraphql/graphql-playground/blob/master/packages/graphql-playground-react/src/localDevIndex.tsx#L47)
85+
- `settings` [`ISettings`](optional) - Editor settings in json format as [described here](https://github.com/prismagraphql/graphql-playground#settings)
8686

8787
```ts
8888
interface ISettings {
89-
'general.betaUpdates': boolean
90-
'editor.theme': Theme
91-
'editor.reuseHeaders': boolean
92-
'tracing.hideTracingResponse': boolean
93-
'editor.fontSize': number
94-
'editor.fontFamily': string
95-
'request.credentials': string
89+
'general.betaUpdates': boolean
90+
'editor.theme': Theme
91+
'editor.reuseHeaders': boolean
92+
'tracing.hideTracingResponse': boolean
93+
'editor.fontSize': number
94+
'editor.fontFamily': string
95+
'request.credentials': string
96+
'schema.disableComments': boolean
9697
}
9798
```
9899

99-
* `schema` [`IntrospectionResult`](optional) - The result of an introspection query (an object of this form: `{__schema: {...}}`) The playground automatically fetches the schema from the endpoint. This is only needed when you want to override the schema.
100-
* `tabs` [`Tab[]`](optional) - An array of tabs to inject. **Note: When using this feature, tabs will be resetted each time the page is reloaded**
100+
- `schema` [`IntrospectionResult`](optional) - The result of an introspection query (an object of this form: `{__schema: {...}}`) The playground automatically fetches the schema from the endpoint. This is only needed when you want to override the schema.
101+
- `tabs` [`Tab[]`](optional) - An array of tabs to inject. **Note: When using this feature, tabs will be resetted each time the page is reloaded**
101102

102103
```ts
103104
interface Tab {
104-
endpoint: string
105-
query: string
106-
name?: string
107-
variables?: string
108-
responses?: string[]
109-
headers?: { [key: string]: string }
105+
endpoint: string
106+
query: string
107+
name?: string
108+
variables?: string
109+
responses?: string[]
110+
headers?: { [key: string]: string }
110111
}
111112
```
112113

113114
In addition to this, the React app provides some more properties:
114115

115-
* `props` (React Component)
116-
* `createApolloLink` [`(session: Session) => ApolloLink`] - this is the equivalent to the `fetcher` of GraphiQL. For each query that is being executed, this function will be called
116+
- `props` (React Component)
117+
- `createApolloLink` [`(session: Session) => ApolloLink`] - this is the equivalent to the `fetcher` of GraphiQL. For each query that is being executed, this function will be called
117118

118119
`createApolloLink` is only available in the React Component and not the middlewares, because the content must be serializable as it is being printed into a HTML template.
119120

@@ -145,7 +146,10 @@ The GraphQL Playground requires **React 16**.
145146
Including Fonts (`1.`)
146147

147148
```html
148-
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|Source+Code+Pro:400,700" rel="stylesheet">
149+
<link
150+
href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700|Source+Code+Pro:400,700"
151+
rel="stylesheet"
152+
/>
149153
```
150154

151155
Including stylesheet and the component (`2., 3.`)
@@ -157,10 +161,10 @@ import { Provider } from 'react-redux'
157161
import { Playground, store } from 'graphql-playground-react'
158162

159163
ReactDOM.render(
160-
<Provider store={store}>
161-
<Playground endpoint="https://api.graph.cool/simple/v1/swapi" />
162-
</Provider>,
163-
document.body,
164+
<Provider store={store}>
165+
<Playground endpoint="https://api.graph.cool/simple/v1/swapi" />
166+
</Provider>,
167+
document.body,
164168
)
165169
```
166170

@@ -180,13 +184,13 @@ yarn add graphql-playground-middleware-lambda
180184

181185
We have a full example for each of the frameworks below:
182186

183-
* **Express:** See [packages/graphql-playground-middleware-express/examples/basic](https://github.com/prismagraphql/graphql-playground/tree/master/packages/graphql-playground-middleware-express/examples/basic)
187+
- **Express:** See [packages/graphql-playground-middleware-express/examples/basic](https://github.com/prismagraphql/graphql-playground/tree/master/packages/graphql-playground-middleware-express/examples/basic)
184188

185-
* **Hapi:** See [packages/graphql-playground-middleware-hapi](https://github.com/prismagraphql/graphql-playground/tree/master/packages/graphql-playground-middleware-hapi)
189+
- **Hapi:** See [packages/graphql-playground-middleware-hapi](https://github.com/prismagraphql/graphql-playground/tree/master/packages/graphql-playground-middleware-hapi)
186190

187-
* **Koa:** See [packages/graphql-playground-middleware-koa](https://github.com/prismagraphql/graphql-playground/tree/master/packages/graphql-playground-middleware-koa)
191+
- **Koa:** See [packages/graphql-playground-middleware-koa](https://github.com/prismagraphql/graphql-playground/tree/master/packages/graphql-playground-middleware-koa)
188192

189-
* **Lambda (as serverless handler):** See [serverless-graphql-apollo](https://github.com/serverless/serverless-graphql-apollo) or a quick example below.
193+
- **Lambda (as serverless handler):** See [serverless-graphql-apollo](https://github.com/serverless/serverless-graphql-apollo) or a quick example below.
190194

191195
### As serverless handler
192196

@@ -206,18 +210,18 @@ import lambdaPlayground from 'graphql-playground-middleware-lambda'
206210
// const lambdaPlayground = require('graphql-playground-middleware-lambda').default
207211

208212
exports.graphqlHandler = function graphqlHandler(event, context, callback) {
209-
function callbackFilter(error, output) {
210-
// eslint-disable-next-line no-param-reassign
211-
output.headers['Access-Control-Allow-Origin'] = '*'
212-
callback(error, output)
213-
}
214-
215-
const handler = graphqlLambda({ schema: myGraphQLSchema })
216-
return handler(event, context, callbackFilter)
213+
function callbackFilter(error, output) {
214+
// eslint-disable-next-line no-param-reassign
215+
output.headers['Access-Control-Allow-Origin'] = '*'
216+
callback(error, output)
217+
}
218+
219+
const handler = graphqlLambda({ schema: myGraphQLSchema })
220+
return handler(event, context, callbackFilter)
217221
}
218222

219223
exports.playgroundHandler = lambdaPlayground({
220-
endpoint: '/dev/graphql',
224+
endpoint: '/dev/graphql',
221225
})
222226
```
223227

@@ -228,17 +232,17 @@ functions:
228232
graphql:
229233
handler: handler.graphqlHandler
230234
events:
231-
- http:
232-
path: graphql
233-
method: post
234-
cors: true
235+
- http:
236+
path: graphql
237+
method: post
238+
cors: true
235239
playground:
236240
handler: handler.playgroundHandler
237241
events:
238-
- http:
239-
path: playground
240-
method: get
241-
cors: true
242+
- http:
243+
path: playground
244+
method: get
245+
cors: true
242246
```
243247
244248
## Development
@@ -253,32 +257,33 @@ Open
253257
[localhost:3000/localDev.html?endpoint=https://api.graph.cool/simple/v1/swapi](http://localhost:3000/localDev.html?endpoint=https://api.graph.cool/simple/v1/swapi) for local development!
254258

255259
## Custom Theme
260+
256261
From `[email protected]` on you can provide a `codeTheme` property to the React Component to customize your color theme.
257262
These are the available options:
258-
```ts
259263

264+
```ts
260265
export interface EditorColours {
261-
property: string
262-
comment: string
263-
punctuation: string
264-
keyword: string
265-
def: string
266-
qualifier: string
267-
attribute: string
268-
number: string
269-
string: string
270-
builtin: string
271-
string2: string
272-
variable: string
273-
meta: string
274-
atom: string
275-
ws: string
276-
selection: string
277-
cursorColor: string
278-
editorBackground: string
279-
resultBackground: string
280-
leftDrawerBackground: string
281-
rightDrawerBackground: string
266+
property: string
267+
comment: string
268+
punctuation: string
269+
keyword: string
270+
def: string
271+
qualifier: string
272+
attribute: string
273+
number: string
274+
string: string
275+
builtin: string
276+
string2: string
277+
variable: string
278+
meta: string
279+
atom: string
280+
ws: string
281+
selection: string
282+
cursorColor: string
283+
editorBackground: string
284+
resultBackground: string
285+
leftDrawerBackground: string
286+
rightDrawerBackground: string
282287
}
283288
```
284289

@@ -290,13 +295,13 @@ This is repository is a "mono repo" and contains multiple packages using [Yarn w
290295

291296
In the folder `packages` you'll find the following packages:
292297

293-
* `graphql-playground-electron`: Cross-platform electron app which uses `graphql-playground-react`
294-
* `graphql-playground-html`: Simple HTML page rendering a version of `graphql-playground-react` hosted on JSDeliver
295-
* `graphql-playground-middleware-express`: Express middleware using `graphql-playground-html`
296-
* `graphql-playground-middleware-hapi`: Hapi middleware using `graphql-playground-html`
297-
* `graphql-playground-middleware-koa`: Koa middleware using `graphql-playground-html`
298-
* `graphql-playground-middleware-lambda`: AWS Lambda middleware using `graphql-playground-html`
299-
* `graphql-playground-react`: Core of GraphQL Playground built with ReactJS
298+
- `graphql-playground-electron`: Cross-platform electron app which uses `graphql-playground-react`
299+
- `graphql-playground-html`: Simple HTML page rendering a version of `graphql-playground-react` hosted on JSDeliver
300+
- `graphql-playground-middleware-express`: Express middleware using `graphql-playground-html`
301+
- `graphql-playground-middleware-hapi`: Hapi middleware using `graphql-playground-html`
302+
- `graphql-playground-middleware-koa`: Koa middleware using `graphql-playground-html`
303+
- `graphql-playground-middleware-lambda`: AWS Lambda middleware using `graphql-playground-html`
304+
- `graphql-playground-react`: Core of GraphQL Playground built with ReactJS
300305

301306
<a name="help-and-community" />
302307

packages/graphql-playground-react/src/components/Playground/DocExplorer/DocsStyles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Title = styled.div`
66
cursor: default;
77
font-size: 14px;
88
font-weight: 600;
9-
text-transform: uppercase;
9+
text-transform: uppercase !important;
1010
letter-spacing: 1px;
1111
padding: 16px;
1212
user-select: none;

packages/graphql-playground-react/src/components/Playground/DocExplorer/DocsTypes/EnumTypeSchema.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { DocType } from './DocType'
44

55
export interface EnumTypeSchemaProps {
66
type: any
7+
sdlType?: boolean
78
}
89

9-
const EnumTypeSchema = ({ type }: EnumTypeSchemaProps) => {
10-
const values = type.getValues()
10+
const EnumTypeSchema = ({ type, sdlType }: EnumTypeSchemaProps) => {
11+
const values = sdlType ? type._values : type.getValues()
1112
const deprecatedValues = values.filter((value: any) => value.isDeprecated)
1213
return (
1314
<DocType className="doc-type-schema">
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { styled } from '../../../styled'
2+
export const ErrorContainer = styled.div`
3+
font-weight: bold;
4+
left: 0;
5+
letter-spacing: 1px;
6+
opacity: 0.5;
7+
position: absolute;
8+
right: 0;
9+
text-align: center;
10+
text-transform: uppercase;
11+
top: 50%;
12+
transform: translate(0, -50%);
13+
`

0 commit comments

Comments
 (0)