Skip to content

Commit 2c51846

Browse files
committedNov 20, 2018
fix: Change cache key from typedefs to endpoint
Fixes #81
1 parent d06c79b commit 2c51846

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed
 

Diff for: ‎src/Prisma.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class Prisma extends Binding {
4444
const token = secret ? sign({}, secret!) : undefined
4545
const link = makePrismaLink({ endpoint: endpoint!, token, debug })
4646

47-
const remoteSchema = getCachedRemoteSchema(typeDefs, sharedLink)
47+
const remoteSchema = getCachedRemoteSchema(endpoint, typeDefs, sharedLink)
4848

4949
const before = () => {
5050
sharedLink.setInnerLink(link)

Diff for: ‎src/cache.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { SharedLink } from './SharedLink'
44
import { makeRemoteExecutableSchema } from 'graphql-tools'
55

66
const typeDefsCache: { [schemaPath: string]: string } = {}
7-
const remoteSchemaCache: { [typeDefs: string]: GraphQLSchema } = {}
7+
const remoteSchemaCache: { [endpoint: string]: GraphQLSchema } = {}
88

99
export function getCachedTypeDefs(schemaPath: string): string {
1010
if (typeDefsCache[schemaPath]) {
@@ -18,19 +18,19 @@ export function getCachedTypeDefs(schemaPath: string): string {
1818
}
1919

2020
export function getCachedRemoteSchema(
21+
endpoint: string,
2122
typeDefs: string,
2223
link: SharedLink,
2324
): GraphQLSchema {
24-
if (remoteSchemaCache[typeDefs]) {
25-
return remoteSchemaCache[typeDefs]
25+
if (remoteSchemaCache[endpoint]) {
26+
return remoteSchemaCache[endpoint]
2627
}
2728

2829
const remoteSchema = makeRemoteExecutableSchema({
29-
// TODO fix typings
30-
link: link as any,
30+
link: link,
3131
schema: typeDefs,
3232
})
33-
remoteSchemaCache[typeDefs] = remoteSchema
33+
remoteSchemaCache[endpoint] = remoteSchema
3434

3535
return remoteSchema
3636
}

0 commit comments

Comments
 (0)
Please sign in to comment.