-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
StoreFetchMiddleware #376
StoreFetchMiddleware #376
Conversation
Prompted by apollographql#376's brittleness; this helps keep common state/configuration around when performing a query. --- Also, as part of this, I noticed there are two seemingly unused functions: `diffQueryAgainstStore`, `diffFragmentAgainstStore`
33d6f9d
to
a289de1
Compare
Prompted by apollographql#376's brittleness; this helps keep common state/configuration around when performing a query. --- Also, as part of this, I noticed there are two seemingly unused functions: `diffQueryAgainstStore`, `diffFragmentAgainstStore`
a289de1
to
a5db83c
Compare
Prompted by apollographql#376's brittleness; this helps keep common state/configuration around when performing a query. --- Also, as part of this, I noticed there are two seemingly unused functions: `diffQueryAgainstStore`, `diffFragmentAgainstStore`
badf40c
to
d91de58
Compare
d91de58
to
2aeabc9
Compare
Alrighty, rebased & it now handles the new |
2aeabc9
to
ab54ca2
Compare
ab54ca2
to
cf76a22
Compare
Hi guys! I'm currently working on a React Native where we use Apollo Client and StoreFetchMiddleware is exactly what we need actually 😱 !! Are you planning to work on it (maybe merge it?) anytime soon? |
ebd8a49
to
e3b18bf
Compare
+1 |
e3b18bf
to
a31251d
Compare
Curious what you guys think about this PR? |
any update? |
d64335f
to
7858f91
Compare
This makes it quite a bit easier to pass additional configuration to the data/* functions
7858f91
to
a7aa785
Compare
By allowing users to rewrite data lookups from the store, they can satisfy behavior like apollographql#332
a7aa785
to
d1ecb7e
Compare
…eware StoreFetchMiddleware
The test failure is node v4 only with:
|
Could anyone provide feedback? |
@stubailo Can you please provide any estimations on when this pull request will be merged ? |
Hey, sorry I've been a blocker on this PR for a while. I think in order to avoid people manipulating the query AST directly, we should implement this feature after #615, which will let us switch the internal execution implementation to use https://github.com/apollostack/graphql-anywhere This will allow the store fetch middleware to instead be replaced with custom resolvers on the client, which is much more similar to how GraphQL works on the server, rather than using AST manipulation. We're hoping to get this refactor done in the next week or two, so perhaps we can wait until then? However if it's really urgent we can add a more hacky solution first. I'd suggest that the hacky solution should not live in the execution layer, but instead somewhere in query manager, where the query can be transformed before being passed into |
Waiting 2 weeks (or a bit more) is just fine for me... I was worried 'cause this is an essential feature. |
Yeah, I agree it's important to be able to use data from the cache, even if you are running a different query. I think it will be way easier after a refactor though, which might also come with a bonus of using any client-side data from GraphQL. |
Yeah, local resolvers would be a much better solution |
Yeah, if you look at the conversation above we concluded that this feature can be implemented in a much better way after a refactor. Then, you don't have to manipulate the AST, instead you'll be able to define custom client-side resolvers. |
Gotcha. I saw that. I presumed this PR would reworked accordingly. It would be better to submit an entirely new PR. Thanks! |
StoreFetchMiddleware allows the caller to rewrite fetches from the store (for example, to redirect a read to another node)
This also includes a reference implementation to cover the case outlined by #332 (and I suspect the primary use of this middleware):
Also, FYI, Mocha is promise-aware - just return the promise from a test, and it'll take care of the rest! No need to use
done