Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
fix(base): update apollo server to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
patte committed Oct 31, 2018
1 parent 2214921 commit 824d5e3
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 58 deletions.
21 changes: 11 additions & 10 deletions packages/base/express/graphql.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const bodyParser = require('body-parser')
const { graphiqlExpress } = require('apollo-server-express')
const playground = require('graphql-playground-middleware-express').default
const { SubscriptionServer } = require('subscriptions-transport-ws')
const { execute, subscribe } = require('graphql')
const { execute, subscribe, formatError: baseFormatError } = require('graphql')
const { pubsub } = require('../lib/RedisPubSub')
const cookie = require('cookie')
const cookieParser = require('cookie-parser')
Expand Down Expand Up @@ -36,8 +36,8 @@ function graphqlExpress (options) {
options: options,
query: req.method === 'POST' ? req.body : req.query
}).then(
originalGQLResponse => {
let gqlResponse = originalGQLResponse
originalResponse => {
let gqlResponse = originalResponse.graphqlResponse
const ua = req.headers['user-agent']

if (ua && ua.includes('RepublikApp') && (
Expand Down Expand Up @@ -84,7 +84,7 @@ module.exports = (
executableSchema,
externalCreateGraphQLContext = a => a
) => {
const createContext = ({user, ...additional} = {}) => externalCreateGraphQLContext({
const createContext = ({ user, ...additional } = {}) => externalCreateGraphQLContext({
...additional,
pgdb,
user,
Expand Down Expand Up @@ -113,7 +113,7 @@ module.exports = (
)
const session = sid && await pgdb.public.sessions.findOne({ sid })
if (session) {
const user = await pgdb.public.users.findOne({id: session.sess.passport.user})
const user = await pgdb.public.users.findOne({ id: session.sess.passport.user })
return createContext({
user: transformUser(user)
})
Expand All @@ -132,11 +132,12 @@ module.exports = (
return {
debug: false,
formatError (error) {
const { extensions, ...rest } = baseFormatError(error)
console.log(
`graphql error in ${this.operationName} (${JSON.stringify(this.variables)}):`,
error
)
return error
return { ...extensions, ...rest }
},
schema: executableSchema,
context: createContext({
Expand All @@ -150,12 +151,12 @@ module.exports = (
server.use('/graphql',
[
RES_KEEPALIVE ? require('./keepalive') : null,
bodyParser.json({limit: '128mb'}),
bodyParser.json({ limit: '128mb' }),
graphqlMiddleware
].filter(Boolean)
)
server.use('/graphiql', graphiqlExpress({
endpointURL: '/graphql',
server.use('/graphiql', playground({
endpoint: '/graphql',
subscriptionsEndpoint: PUBLIC_WS_URL_BASE + PUBLIC_WS_URL_PATH
}))

Expand Down
1 change: 1 addition & 0 deletions packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"elasticsearch": "^15.0.0",
"export-files": "^2.1.1",
"express": "^4.16.3",
"graphql-playground-middleware-express": "^1.7.6",
"graphql-redis-subscriptions": "^2.0.0",
"graphql-subscriptions": "^1.0.0",
"helmet": "^3.13.0",
Expand Down
113 changes: 65 additions & 48 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1285,11 +1285,6 @@ binary-extensions@^1.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.12.0.tgz#c2d780f53d45bba8317a8902d4ceeaf3a6385b14"
integrity sha512-DYWGk01lDcxeS/K9IHPGWfT8PsJmbXRtRd2Sx72Tnb8pcYZQFF1oSDb8hJtS1vhp212q1Rzi5dUf9+nq0o9UIg==

bindings@^1.2.1:
version "1.3.0"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"
integrity sha512-DpLh5EzMR2kzvX1KIlVC0VkC3iZtHKTgdtZ0a3pglBZdaQFjt5S9g9xd1lE+YvXyfd6mtCeRnrUfOLYiTMlNSw==

bl@^1.0.0:
version "1.2.2"
resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.2.tgz#a160911717103c07410cef63ef51b397c025af9c"
Expand Down Expand Up @@ -2077,6 +2072,14 @@ cron@^1.3.0:
dependencies:
moment-timezone "^0.5.x"

cross-fetch@2.2.2:
version "2.2.2"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-2.2.2.tgz#a47ff4f7fc712daba8f6a695a11c948440d45723"
integrity sha1-pH/09/xxLauo9qaVoRyUhEDUVyM=
dependencies:
node-fetch "2.1.2"
whatwg-fetch "2.0.4"

cross-fetch@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-1.1.1.tgz#dede6865ae30f37eae62ac90ebb7bdac002b05a0"
Expand Down Expand Up @@ -2178,7 +2181,7 @@ d3-chord@1:
d3-array "1"
d3-path "1"

d3-collection@1, d3-collection@^1.0.7:
d3-collection@1:
version "1.0.7"
resolved "https://registry.yarnpkg.com/d3-collection/-/d3-collection-1.0.7.tgz#349bd2aa9977db071091c13144d5e4f16b5b310e"
integrity sha512-ii0/r5f4sjKNTfh84Di+DpztYwqKhEyUlKoPrzUFfeSkWxjW49xU2QzO9qrPrNkpdI0XJkfzvmTu8V2Zylln6A==
Expand Down Expand Up @@ -3176,19 +3179,6 @@ etag@~1.8.1:
resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887"
integrity sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=

event-stream@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-4.0.1.tgz#4092808ec995d0dd75ea4580c1df6a74db2cde65"
integrity sha512-qACXdu/9VHPBzcyhdOWR5/IahhGMf0roTeZJfzz077GwylcDd90yOHLouhmv7GJ5XzPi6ekaQWd8AvPP2nOvpA==
dependencies:
duplexer "^0.1.1"
from "^0.1.7"
map-stream "0.0.7"
pause-stream "^0.0.11"
split "^1.0.1"
stream-combiner "^0.2.2"
through "^2.3.8"

event-stream@~3.3.0:
version "3.3.6"
resolved "https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.6.tgz#cac1230890e07e73ec9cacd038f60a5b66173eef"
Expand Down Expand Up @@ -4232,6 +4222,17 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6:
resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725"
integrity sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=

graphql-config@2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/graphql-config/-/graphql-config-2.2.1.tgz#5fd0ec77ac7428ca5fb2026cf131be10151a0cb2"
integrity sha512-U8+1IAhw9m6WkZRRcyj8ZarK96R6lQBQ0an4lp76Ps9FyhOXENC5YQOxOFGm5CxPrX2rD0g3Je4zG5xdNJjwzQ==
dependencies:
graphql-import "^0.7.1"
graphql-request "^1.5.0"
js-yaml "^3.10.0"
lodash "^4.17.4"
minimatch "^3.0.4"

graphql-extensions@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/graphql-extensions/-/graphql-extensions-0.2.1.tgz#7697e0fcea2e622afe9e24dd31fc84f533e84c70"
Expand All @@ -4244,10 +4245,32 @@ graphql-fields@^1.0.2:
resolved "https://registry.yarnpkg.com/graphql-fields/-/graphql-fields-1.2.1.tgz#3777112af0bd6f55cc3c7b8f6d7748ab7a1b23bb"
integrity sha512-ufg/dxb78IjQUblNfiaEMkZWD1CwcZjdK0nTEW0dBQyNArxKZI7N+zohZdIdqVJcihPWJod1yymx4NM+1bZjTw==

graphql-import@^0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/graphql-import/-/graphql-import-0.7.1.tgz#4add8d91a5f752d764b0a4a7a461fcd93136f223"
integrity sha512-YpwpaPjRUVlw2SN3OPljpWbVRWAhMAyfSba5U47qGMOSsPLi2gYeJtngGpymjm9nk57RFWEpjqwh4+dpYuFAPw==
dependencies:
lodash "^4.17.4"
resolve-from "^4.0.0"

"graphql-list-fields@https://github.com/orbiting/graphql-list-fields#named-inline-fragments":
version "2.0.1"
resolved "https://github.com/orbiting/graphql-list-fields#e96ee15199283acb43ced006e777c985c910ed4c"

graphql-playground-html@1.6.4:
version "1.6.4"
resolved "https://registry.yarnpkg.com/graphql-playground-html/-/graphql-playground-html-1.6.4.tgz#be7c5a6213d67aeedf03d90b7e7d55fec4d42212"
integrity sha512-mnpAVYSR3TesYsJ5OLJVJMA0muTCw4npsCI1cKMtW35lbA6KljZkLkz3ZWXhEIYPnHKIeUHEtbn1ZGkEXtAxLg==
dependencies:
graphql-config "2.2.1"

graphql-playground-middleware-express@^1.7.6:
version "1.7.6"
resolved "https://registry.yarnpkg.com/graphql-playground-middleware-express/-/graphql-playground-middleware-express-1.7.6.tgz#aca38d2b8e5147914fc8fa613d151edd4ed0bc44"
integrity sha512-fICPxYGIdhCxtFlwCnP3uZ2uRWeQ9wj7OkcWUiHNwaFma2TbRD5nNKaPA2u21YWha9xv26qIDxxcdW27F/lcbQ==
dependencies:
graphql-playground-html "1.6.4"

graphql-redis-subscriptions@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/graphql-redis-subscriptions/-/graphql-redis-subscriptions-2.0.0.tgz#d904cf1a8898c2019eb1074940f003033cbbc7ea"
Expand All @@ -4257,6 +4280,13 @@ graphql-redis-subscriptions@^2.0.0:
optionalDependencies:
ioredis "^3.1.2"

graphql-request@^1.5.0:
version "1.8.2"
resolved "https://registry.yarnpkg.com/graphql-request/-/graphql-request-1.8.2.tgz#398d10ae15c585676741bde3fc01d5ca948f8fbe"
integrity sha512-dDX2M+VMsxXFCmUX0Vo0TopIZIX4ggzOtiCsThgtrKR4niiaagsGTDIHj3fsOMFETpa064vzovI+4YV4QnMbcg==
dependencies:
cross-fetch "2.2.2"

graphql-subscriptions@^0.5.8:
version "0.5.8"
resolved "https://registry.yarnpkg.com/graphql-subscriptions/-/graphql-subscriptions-0.5.8.tgz#13a6143c546bce390404657dc73ca501def30aa7"
Expand Down Expand Up @@ -6258,7 +6288,7 @@ mute-stream@0.0.7, mute-stream@~0.0.4:
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"
integrity sha1-MHXOk7whuPq0PhvE2n6BFe0ee6s=

nan@^2.0.0, nan@^2.1.0, nan@^2.11.1, nan@^2.9.2:
nan@^2.0.0, nan@^2.11.1, nan@^2.9.2:
version "2.11.1"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.11.1.tgz#90e22bccb8ca57ea4cd37cc83d3819b52eea6766"
integrity sha512-iji6k87OSXa0CcrLl9z+ZiYSuR2o+c0bGuNmXdrhTQTakxytAFsC56SArGYoiHlJlFoHSnvmhpceZJaXkVuOtA==
Expand Down Expand Up @@ -6334,6 +6364,11 @@ node-fetch@1.7.3, node-fetch@^1.0.1:
encoding "^0.1.11"
is-stream "^1.0.1"

node-fetch@2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.1.2.tgz#ab884e8e7e57e38a944753cec706f788d1768bb5"
integrity sha1-q4hOjn5X44qUR1POxwb3iNF2i7U=

node-fetch@^2.1.1, node-fetch@^2.1.2, node-fetch@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.2.0.tgz#4ee79bde909262f9775f731e3656d0db55ced5b5"
Expand Down Expand Up @@ -6366,14 +6401,6 @@ node-localstorage@~1.3.0:
dependencies:
write-file-atomic "^1.1.4"

node-postal@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/node-postal/-/node-postal-1.0.0.tgz#dc4c8bf06cd7a47c9dd65a7dcc323954f943f668"
integrity sha1-3EyL8GzXpHyd1lp9zDI5VPlD9mg=
dependencies:
bindings "^1.2.1"
nan "^2.1.0"

node-pre-gyp@^0.10.0:
version "0.10.3"
resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.10.3.tgz#3070040716afdc778747b61b6887bf78880b80fc"
Expand Down Expand Up @@ -6962,14 +6989,6 @@ path-type@^3.0.0:
dependencies:
pify "^3.0.0"

path@^0.12.7:
version "0.12.7"
resolved "https://registry.yarnpkg.com/path/-/path-0.12.7.tgz#d4dc2a506c4ce2197eb481ebfcd5b36c0140b10f"
integrity sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=
dependencies:
process "^0.11.1"
util "^0.10.3"

pause-stream@^0.0.11:
version "0.0.11"
resolved "https://registry.yarnpkg.com/pause-stream/-/pause-stream-0.0.11.tgz#fe5a34b0cbce12b5aa6a2b403ee2e73b602f1445"
Expand Down Expand Up @@ -7382,11 +7401,6 @@ process@^0.10.0:
resolved "https://registry.yarnpkg.com/process/-/process-0.10.1.tgz#842457cc51cfed72dc775afeeafb8c6034372725"
integrity sha1-hCRXzFHP7XLcd1r+6vuMYDQ3JyU=

process@^0.11.1:
version "0.11.10"
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI=

progress@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
Expand Down Expand Up @@ -8016,6 +8030,11 @@ resolve-from@^1.0.0:
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"
integrity sha1-Jsv+k10a7uq7Kbw/5a6wHpPUQiY=

resolve-from@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6"
integrity sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==

resolve-url@^0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
Expand Down Expand Up @@ -9477,13 +9496,6 @@ util.promisify@^1.0.0:
define-properties "^1.1.2"
object.getownpropertydescriptors "^2.0.3"

util@^0.10.3:
version "0.10.4"
resolved "https://registry.yarnpkg.com/util/-/util-0.10.4.tgz#3aa0125bfe668a4672de58857d3ace27ecb76901"
integrity sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==
dependencies:
inherits "2.0.3"

utile@0.3.x:
version "0.3.0"
resolved "https://registry.yarnpkg.com/utile/-/utile-0.3.0.tgz#1352c340eb820e4d8ddba039a4fbfaa32ed4ef3a"
Expand Down Expand Up @@ -9612,6 +9624,11 @@ whatwg-fetch@2.0.3:
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
integrity sha1-nITsLc9oGH/wC8ZOEnS0QhduHIQ=

whatwg-fetch@2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
integrity sha512-dcQ1GWpOD/eEQ97k66aiEVpNnapVj90/+R+SXTPYGHpYBBypfKJEQjLrvMZ7YXbKm21gXd4NcuxUTjiv1YtLng==

whatwg-fetch@>=0.10.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-3.0.0.tgz#fc804e458cc460009b1a2b966bc8817d2578aefb"
Expand Down

0 comments on commit 824d5e3

Please sign in to comment.