Skip to content

Commit

Permalink
feat: Add disableCache option
Browse files Browse the repository at this point in the history
src: add option to disable method cache
  • Loading branch information
maticzav committed Jan 26, 2019
2 parents 3a2ba7c + b747d93 commit f2aaac3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Binding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,21 @@ export class Binding extends Delegate {
query: QueryMap
mutation: MutationMap
subscription: SubscriptionMap
disableCache: boolean

constructor({ schema, fragmentReplacements, before }: BindingOptions) {
constructor({
schema,
fragmentReplacements,
before,
disableCache,
}: BindingOptions) {
super({ schema, fragmentReplacements, before })

const { query, mutation, subscription } = this.buildMethods()
this.query = query
this.mutation = mutation
this.subscription = subscription
this.disableCache = disableCache || false
}

buildMethods() {
Expand All @@ -34,7 +41,9 @@ export class Binding extends Delegate {
mutation: this.buildQueryMethods('mutation'),
subscription: this.buildSubscriptionMethods(),
}
methodCache.set(this.schema, methods)
if (!this.disableCache) {
methodCache.set(this.schema, methods)
}
return methods
}

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface BindingOptions {
fragmentReplacements?: FragmentReplacement[]
schema: GraphQLSchema
before?: () => void
disableCache?: boolean
}

export interface BindingWithoutSchemaOptions {
Expand Down

0 comments on commit f2aaac3

Please sign in to comment.