apollo-datasource-dynamodb icon indicating copy to clipboard operation
apollo-datasource-dynamodb copied to clipboard

Calling DynamoDBDataSource.initialize isn't documented

Open strefethen opened this issue 4 years ago • 1 comments

I've created a subclass and upon first calling getMyItem it calls the inherited getItem which is implemented through the caching mechanism which isn't initialized unless initialize is explicitly called. It looks like reasonable defaults are specified so it seems like it could work without requiring the initialize call. In my own code I had to do the following:

export var CHPDS = new CHPIncidentsDS(defaultConfiguration);
CHPDS.initialize({ context: CHPDS.dynamoDbDocClient, cache: new InMemoryLRUCache() });

I see in the cache class that "new InMemoryLRUCache()" is the default value but when calling initialize the complier won't let me only pass the "context" key therefore the default for the cache param isn't used.

strefethen avatar Nov 28 '20 04:11 strefethen

This came from a port I did initially when creating this lib following the examples in the RestDataSource. I agree with you. I will think on this on how to have some more intelligent methods (or at least documentation) on how to use the initialize.

cmwhited avatar Dec 05 '20 06:12 cmwhited