-
Notifications
You must be signed in to change notification settings - Fork 28
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
remove id from the @cached directive #127
Comments
I saw these changes reflected in the latest Action PR. Could you help illustrate how this works without Let's use an example: const projectCardSubQuery = `
query {
project @cached(type: "Project") {
content
id
status
teamMemberId
updatedAt
teamMember @cached(type: "TeamMember") {
id
picture
preferredName
}
team @cached(type: "Team") {
id
name
}
}
}
`;
const mapStateToProps = (state, props) => {
const userId = state.auth.obj.sub;
const [teamId] = props.project.id.split('::');
const projectId = props.project.id;
const {project} = cashay.query(projectCardSubQuery, {
op: 'projectCardContainer',
key: projectId,
variables: {projectId},
resolveCached: {
project: () => projectId,
team: (source) => (doc) => source.id.startsWith(doc.id),
// example of returning a string instead of a function so it runs in O(1)
teamMember: (source) => source.teamMemberId
},
}).data; So How does this work? does the Is that right? |
Yep! I could probably elucidate this a little better in the docs, but basically each method in If it returns a string, in this case Next, look at the
Finally, just like you said, the |
They way you just wrote about it here is super, super clear. This would be great for the docs! |
the
id, ids
fields are pretty useless & can use a pre-cached value causing source.id to come up undefined. It's not terrible, but it causes an extra render. Plus this makes for a smaller, more opinionated API.The text was updated successfully, but these errors were encountered: