diff --git a/packages/apollo-server-core/src/ApolloServer.test.ts b/packages/apollo-server-core/src/ApolloServer.test.ts index 9452013e054..944c8f7b4e9 100644 --- a/packages/apollo-server-core/src/ApolloServer.test.ts +++ b/packages/apollo-server-core/src/ApolloServer.test.ts @@ -905,6 +905,9 @@ describe('ApolloServerBase', () => { server = new ApolloServerBase({ schema, introspection: false, + persistedQueries: { + cache: new Map() as any, + }, }); const httpServer = createHttpServer(server); @@ -912,7 +915,6 @@ describe('ApolloServerBase', () => { server.use({ getHttp: () => httpServer, path: '/graphql', - cache: new Map() as any, }); uri = (await server.listen()).url; }); diff --git a/packages/apollo-server-core/src/runHttpQuery.ts b/packages/apollo-server-core/src/runHttpQuery.ts index f9f1b43f95b..a18f80a7fb7 100644 --- a/packages/apollo-server-core/src/runHttpQuery.ts +++ b/packages/apollo-server-core/src/runHttpQuery.ts @@ -1,5 +1,5 @@ import { ExecutionResult } from 'graphql'; -import * as sha256 from 'hash.js/lib/hash/sha/256'; +import sha256 from 'hash.js/lib/hash/sha/256'; import { runQuery, QueryOptions } from './runQuery'; import { @@ -198,21 +198,22 @@ export async function runHttpQuery( } //Do the store completely asynchronously - Promise.resolve().then(() => { - //We do not wait on the cache storage to complete - optionsObject.persistedQueries.cache - .set(sha, queryString) - .catch(error => { - if (optionsObject.logFunction) { - optionsObject.logFunction({ - action: LogAction.setup, - step: LogStep.status, - key: 'error', - data: error, - }); - } - }); - }); + Promise.resolve() + .then(() => { + //We do not wait on the cache storage to complete + return optionsObject.persistedQueries.cache.set(sha, queryString); + }) + .catch(error => { + console.log(error); + if (optionsObject.logFunction) { + optionsObject.logFunction({ + action: LogAction.setup, + step: LogStep.status, + key: 'error', + data: error, + }); + } + }); } }