Skip to content
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

Cache redirects #921

Merged
merged 13 commits into from
Nov 16, 2016
Merged

Cache redirects #921

merged 13 commits into from
Nov 16, 2016

Conversation

helfer
Copy link
Contributor

@helfer helfer commented Nov 16, 2016

These are the cherry-picked commits from #809 to implement only cache redirects (and not yet fully support client-side computed fields).

TODO:

  • If this PR is a new feature, reference an issue where a consensus about the design was reached (not necessary for small changes)
  • Make sure all of the significant new logic is covered by tests
  • Rebase your changes on master so that they can be merged easily
  • Make sure all tests and linter rules pass
  • Update CHANGELOG.md with your change
  • Add your name and email to the AUTHORS file (optional)
  • If this was a change that affects the external API, update the docs and post a link to the PR in the discussion

@helfer helfer mentioned this pull request Nov 16, 2016
13 tasks
@helfer
Copy link
Contributor Author

helfer commented Nov 16, 2016

@stubailo please review this when you have a minute. I think it should work, but a second pair of eyeballs on this would be good.

Copy link
Contributor

@stubailo stubailo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be simplified since the stuff around the ID is mostly boilerplate.

customResolvers: {
Query: {
person: (_, args) => {
return {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this is probably not the optimal API right? Perhaps we should change this so that people can just return the ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, yes, good catch! I patched the tests to get things working and then forgot to build that in.

generated: false,
};
},
person: (_, args) => toIdValue(args['id']),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, let's talk about this.

@helfer
Copy link
Contributor Author

helfer commented Nov 16, 2016

@stubailo I added a toIdValue helper function, which I think is the right way to go, because we want people to indicate if they're returning an id vs. just an object from the resolver.

@stubailo
Copy link
Contributor

because we want people to indicate if they're returning an id vs. just an object from the resolver.

Why?

@helfer
Copy link
Contributor Author

helfer commented Nov 16, 2016

How would you tell apart an id from a string otherwise? Personally I'm in favor of having as little fancy magic under the hood as possible, and making people use toIdValue seems like not too much of an ask.

@helfer helfer merged commit 5ffe05d into master Nov 16, 2016
@helfer
Copy link
Contributor Author

helfer commented Nov 16, 2016

I don't know why I already merged this. I still need to update the changelog and write docs for it...

@TSMMark
Copy link

TSMMark commented Nov 17, 2016

Does this fix pagination? I have a component which utilizes pagination, but it fetches data every time the component mounts, even if the data from the exact same query is already cached in redux. Is this a known issue?

Edit: I opened issue #933

@jbaxleyiii jbaxleyiii deleted the cache-redirects branch July 20, 2017 17:41
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants