You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ This package uses [DataLoader](https://github.com/graphql/dataloader) for batchi
20
20
-[Basic](#basic)
21
21
-[Batching](#batching)
22
22
-[Caching](#caching)
23
+
-[TypeScript](#typescript)
23
24
-[API](#api)
24
25
-[findOneById](#findonebyid)
25
26
-[findManyByIds](#findmanybyids)
@@ -165,6 +166,58 @@ const resolvers = {
165
166
166
167
Here we also call [`deleteFromCacheById()`](#deletefromcachebyid) to remove the user from the cache when the user's data changes. If we're okay with people receiving out-of-date data for the duration of our `ttl`—in this case, for as long as a minute—then we don't need to bother adding calls to `deleteFromCacheById()`.
167
168
169
+
### TypeScript
170
+
171
+
Since we are using a typed language, we want the provided methods to be correctly typed as well. This requires us to make the `MongoDataSource` class polymorphic. It requires 1-2 template arguments. The first argument is the type of the document in our collection. The second argument is the type of context in our GraphQL server, which defaults to `any`. For example:
0 commit comments