Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added NoCacheRESTDataSource #51

Merged
merged 1 commit into from
Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { RESTDataSource } = require('apollo-datasource-rest');
const { NoCacheRESTDataSource } = require('../../../utils/noCacheRESTDataSource');

class TenantIdentityApi extends RESTDataSource {
class TenantIdentityApi extends NoCacheRESTDataSource {
constructor() {
super();
this.baseURL = `${process.env.IDENTITY_API_URL}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { RESTDataSource } = require('apollo-datasource-rest');
const { NoCacheRESTDataSource } = require('../../../utils/noCacheRESTDataSource');

class UserApi extends RESTDataSource {
class UserApi extends NoCacheRESTDataSource {

constructor() {
super();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const { RESTDataSource } = require('apollo-datasource-rest')

class NoCacheRESTDataSource extends RESTDataSource {
deleteCacheForRequest(request) {
this.memoizedResults.delete(this.cacheKeyFor(request))
}

didReceiveResponse(response, request) {
this.deleteCacheForRequest(request)
return super.didReceiveResponse(response, request)
}

didEncounterError(error, request) {
this.deleteCacheForRequest(request)
return super.didEncounterError(error, request)
}
}

module.exports = { NoCacheRESTDataSource }