Skip to content

Commit fc388f1

Browse files
committed
Remove hardcoded version of playground from middlewares
1 parent fa91e1b commit fc388f1

File tree

6 files changed

+12
-33
lines changed

6 files changed

+12
-33
lines changed

packages/graphql-playground-middleware-express/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"files": [
1515
"dist"
1616
],
17-
"playgroundVersion": "1.7.8",
1817
"scripts": {
1918
"build": "rimraf dist && tsc",
2019
"prepare": "npm run build"

packages/graphql-playground-middleware-express/src/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import { Request, Response } from 'express'
22
import {
33
MiddlewareOptions,
4-
RenderPageOptions,
54
renderPlaygroundPage,
65
} from 'graphql-playground-html'
76

87
/* tslint:disable */
9-
const { playgroundVersion } = require('../package.json')
108

119
export type ExpressPlaygroundMiddleware = (
1210
req: Request,
@@ -19,14 +17,9 @@ export type Register = (
1917
) => ExpressPlaygroundMiddleware
2018

2119
const express: Register = function voyagerExpress(options: MiddlewareOptions) {
22-
const middlewareOptions: RenderPageOptions = {
23-
...options,
24-
version: playgroundVersion,
25-
}
26-
2720
return (req, res, next) => {
2821
res.setHeader('Content-Type', 'text/html')
29-
const playground = renderPlaygroundPage(middlewareOptions)
22+
const playground = renderPlaygroundPage(options)
3023
res.write(playground)
3124
res.end()
3225
next()

packages/graphql-playground-middleware-hapi/src/index.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {
55
renderPlaygroundPage,
66
} from 'graphql-playground-html'
77

8-
const pkg = require('../package.json')
9-
108
export interface Register {
119
(server: Server, options: MiddlewareOptions): void
1210
}
@@ -17,26 +15,29 @@ export interface Plugin {
1715
}
1816

1917
const plugin: Plugin = {
20-
pkg,
21-
register: function (server, options: any) {
18+
register: function(server, options: any) {
2219
if (arguments.length !== 2) {
23-
throw new Error(`Playground middleware expects exactly 2 arguments, got ${arguments.length}`)
20+
throw new Error(
21+
`Playground middleware expects exactly 2 arguments, got ${
22+
arguments.length
23+
}`,
24+
)
2425
}
2526

2627
const { path, route: config = {}, ...rest } = options
2728

2829
const middlewareOptions: RenderPageOptions = {
2930
...rest,
30-
version: pkg.playgroundVersion,
3131
}
3232

3333
server.route({
3434
method: 'GET',
3535
path,
3636
config,
37-
handler: (request, h) => h.response(renderPlaygroundPage(middlewareOptions)).type('text/html')
37+
handler: (request, h) =>
38+
h.response(renderPlaygroundPage(middlewareOptions)).type('text/html'),
3839
})
39-
}
40+
},
4041
}
4142

4243
export default plugin

packages/graphql-playground-middleware-koa/src/index.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,18 @@ import { Context } from 'koa'
22
import {
33
MiddlewareOptions,
44
renderPlaygroundPage,
5-
RenderPageOptions,
65
} from 'graphql-playground-html'
76

87
/* tslint:disable-next-line */
9-
const { playgroundVersion } = require('../package.json')
108

119
export type KoaPlaygroundMiddleware = (ctx: Context, next: () => void) => void
1210

1311
export type Register = (options: MiddlewareOptions) => KoaPlaygroundMiddleware
1412

1513
const koa: Register = options => {
16-
const middlewareOptions: RenderPageOptions = {
17-
...options,
18-
version: playgroundVersion,
19-
}
20-
2114
return async function voyager(ctx, next) {
2215
try {
23-
ctx.body = await renderPlaygroundPage(middlewareOptions)
16+
ctx.body = await renderPlaygroundPage(options)
2417
await next()
2518
} catch (err) {
2619
ctx.body = { message: err.message }

packages/graphql-playground-middleware-lambda/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"files": [
1515
"dist"
1616
],
17-
"playgroundVersion": "1.7.8",
1817
"scripts": {
1918
"build": "rimraf dist && tsc",
2019
"prepare": "npm run build"

packages/graphql-playground-middleware-lambda/src/index.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
import * as lambda from 'aws-lambda'
22
import {
33
MiddlewareOptions,
4-
RenderPageOptions,
54
renderPlaygroundPage,
65
} from 'graphql-playground-html'
76

87
/* tslint:disable-next-line */
9-
const { playgroundVersion } = require('../package.json')
108

119
export default function lambdaPlayground(options: MiddlewareOptions) {
1210
return async (
1311
event,
1412
lambdaContext: lambda.Context,
1513
callback: lambda.Callback,
1614
) => {
17-
const middlewareOptions: RenderPageOptions = {
18-
...options,
19-
version: playgroundVersion,
20-
}
21-
const body = await renderPlaygroundPage(middlewareOptions)
15+
const body = await renderPlaygroundPage(options)
2216
callback(null, {
2317
statusCode: 200,
2418
headers: {

0 commit comments

Comments
 (0)