-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
The Problem
Concurrent requests usually happen:
- When resolving multiple fields of the same object.
- When one object appears in multiple locations of a query.
Multiple requests occur and these requests should be deduped if marked as memoizable.
Examples
const resolvers: Resolvers = {
UserInfo: {
name: async ({ mid }, _, { dataSources }) =>
(await dataSources.example.getUserInfo(mid)).name,
gender: async ({ mid }, _, { dataSources }) =>
(await dataSources.example.getUserInfo(mid)).gender,
avatar: async ({ mid }, _, { dataSources }) =>
(await dataSources.example.getUserInfo(mid)).avatar,
},
}query Users {
currentUser {
mid
name
avatar
}
userInfo(mid: 123) {
name
avatar
}
}My suggestion
We should use a lazy loader (like graphql/dataloader but much simpler as we don't need batching and caching).
See #29 for my rough workaround.
Minor question
How to define response.memoize if the response is from deduped result?
Metadata
Metadata
Assignees
Labels
No labels