-
Notifications
You must be signed in to change notification settings - Fork 729
/
localDevIndex.tsx
133 lines (123 loc) · 3.59 KB
/
localDevIndex.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import * as React from 'react'
import * as ReactDOM from 'react-dom'
import MiddlewareApp from './components/MiddlewareApp'
import './index.css'
// import { Tab } from './state/sessions/reducers'
import { LinkCreatorProps } from './state/sessions/fetchingSagas'
import { ApolloLink } from 'apollo-link'
import { HttpLink } from 'apollo-link-http'
// import { exampleSchema } from './fixtures/exampleSchema'
if (process.env.NODE_ENV !== 'production') {
/* tslint:disable-next-line */
// const { whyDidYouUpdate } = require('why-did-you-update')
// whyDidYouUpdate(React)
}
/* tslint:disable-next-line */
;(window as any)['GraphQLPlayground'] = {
init(element: HTMLElement, options) {
ReactDOM.render(
<MiddlewareApp
setTitle={true}
showNewWorkspace={false}
{...options}
// config={config}
// configString={configString}
// codeTheme={lightEditorColours}
// tabs={tabs}
createApolloLink={customLinkCreator}
// schema={exampleSchema}
/>,
element,
)
},
}
// const configString = `projects:
// app:
// schemaPath: "src/schema.graphql"
// extensions:
// endpoints:
// default: "http://localhost:4000"
// database:
// schemaPath: "src/generated/prisma.graphql"
// extensions:
// prisma: database/prisma.yml`
// const config = {
// projects: {
// prisma: {
// schemaPath: 'src/generated/prisma.graphql',
// includes: ['database/seed.graphql'],
// extensions: {
// prisma: 'database/prisma.yml',
// 'prepare-binding': {
// output: 'src/generated/prisma.ts',
// generator: 'prisma-ts',
// },
// endpoints: {
// dev2: {
// url: 'https://eu1.prisma.sh/public-asdf/session65/dev',
// // headers: {
// // Authorization:
// // 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InNlcnZpY2UiOiJhc2RmQGRldiIsInJvbGVzIjpbImFkbWluIl19LCJpYXQiOjE1MjM1MTg3NTYsImV4cCI6MTUyNDEyMzU1Nn0.fzKhXa1JpN9M1UGTbS6p2KMUWDrKLxYD3i3a9eVfOQQ',
// // },
// },
// },
// },
// },
// app: {
// schemaPath: 'src/schema.graphql',
// includes: ['queries/{booking,queries}.graphql'],
// extensions: {
// endpoints: {
// default: 'http://localhost:4000',
// },
// },
// },
// },
// }
// const tabs: Tab[] = [
// {
// query: '{ users { id } }',
// endpoint: 'https://eu1.prisma.sh/public-asdf/session65/dev',
// responses: ['{}'],
// },
// {
// query: '{ users { id } }',
// endpoint: 'https://eu1.prisma.sh/public-asdf/session65/dev',
// },
// ]
const customLinkCreator = (
session: LinkCreatorProps,
wsEndpoint?: string,
): { link: ApolloLink } => {
const { headers, credentials } = session
const link = new HttpLink({
uri: session.endpoint,
fetch,
headers,
credentials,
})
return { link }
}
// const lightEditorColours = {
// property: '#328c8c',
// comment: 'rgba(0, 0, 0, 0.3)',
// punctuation: 'rgba(23,42,58,.8)',
// keyword: '#366b6b',
// def: 'rgb(56, 189, 193)',
// qualifier: '#1c92a9',
// attribute: '#b56531',
// number: '#1f6ed6;',
// string: '#d64292',
// builtin: '#d47509',
// string2: '#0b7fc7',
// variable: 'rgb(236, 95, 103)',
// meta: '#b33086',
// atom: 'rgb(245, 160, 0)',
// ws: 'rgba(23, 42, 58, 0.8)',
// selection: '#d1e9fd',
// cursorColor: 'rgba(0, 0, 0, 0.4)',
// editorBackground: '#f6f7f7',
// resultBackground: '#eeeff0',
// leftDrawerBackground: '#e9eaea',
// rightDrawerBackground: '#e5e7e7',
// }