When executing a request to the server for the second time, the result that returns is always the cached one, even if the first request mutated the entity.
here is the dataSources.js
file that imports two instances of each class of dataSource:
import legacyUserApi from './LegacyUserApi';
import legacyMailApi from './LegacyMailApi';
export default () => ({
legacyUserApi,
legacyMailApi
});
and in the keystone.js
file I import it:
import dataSources from './dataSources';
const apps = [
new GraphQLApp({
apiPath: API_PATH,
apollo: {
dataSources,
introspection: isDev
}
})
]
Keystone js uses Apollo Server
so I've looked at their documentation:
Apollo Server calls this function for every incoming operation. Also as shown, the function should create a new instance of each data source for each operation.
so dataSources.js
file should import the class and not the instance so that Apollo Server will create a new instance with every request.
import LegacyUserApi from './LegacyUserApi';
import LegacyMailApi from './LegacyMailApi';
export default () => ({
legacyUserApi: new LegacyUserApi(),
legacyMailApi: new LegacyMailApi()
});