Comments (10)
What about supporting all the fetch options?
"cache-first" | "cache-and-network" | "network-only" | "cache-only" | "no-cache" | "standby"
I would like to see "cache-and-network"
for my use-cases
from react-apollo-hooks.
@rostero1 Could you please open a separate issue with your question? Let's focus on the roadmap here.
from react-apollo-hooks.
Refactor client+query caching: use react context, add error messages (inherit from react-apollo).
Do you mean replace the WeakMap used in queryCache.js with React context? If so I'm not sure it's a good idea. It was introduced in 246208c to fix #23. React context wouldn't work in the following case:
render(
<Suspense fallback={<MyFallbackComponent />}>
<ApolloProvider client={client}>
<MyComponent />
</ApolloProvider>
</Suspense>
);
If <MyComponent />
were suspended then <ApolloProvider />
would lose its state, and I guess it's a place where you'd like to store the query cache which should be passed by context. Of course, we could require to always use the provider component at the top of the react tree or require users to create the cache outside the tree and pass it as a property, but I think the current solution is the most ergonomic one.
Bundle with rollup, report bundle size.
Do you mean use rollup for creating a UMD version, ready to use with <script>
HTML tags? Are there any benefits of using rollup for creating CJS or ES modules versions?
Find a good way to replace lodash with interal utilities.
Right now only a small subset of lodash is added to the final app bundle, and it may be already added by other libraries. So I'm not sure if moving it to internal utilities would lower its size.
Add more recipes and examples (most developers mindset is not prepared for hooks and Suspense yet).
š Great idea. I'd appreciate any contributions here.
from react-apollo-hooks.
Do you mean replace the WeakMap used in queryCache.js with React context? If so I'm not sure it's a good idea. It was introduced in 246208c to fix #23.
I was thinking about simple context createContext(new WeakMap())
that will use same singleton instance but still allow to inject another WeakMap instance in unit tests.
Do you mean use rollup for creating a UMD version, ready to use with <script> HTML tags? Are there any benefits of using rollup for creating CJS or ES modules versions?
Mostly for rollup-plugin-size-snapshot that allows to track bundle size between PRs. Web community loves to freak out about npm package sizes.
Right now only a small subset of lodash is added to the final app bundle, and it may be already added by other libraries. So I'm not sure if moving it to internal utilities would lower its size.
Lately github introduces new feature that bugs you about unstable libs. So even if my code is 100% stable - I have to publish new version with updated dependency version. That's the reason I'm removing third party utilities from my repos.
But it's just a suggestion.
from react-apollo-hooks.
@lindskogen There are supported right now in the non-suspense mode. With suspense, we'll have to emulate these options. I tried to add support for cache-and-network
in #15. I don't need them right now and not sure I'll have time to work on them in the near future, but I'd accept PR.
from react-apollo-hooks.
I'm very new to apollo and graphql. I might be having some issues with no-cache
and was wondering if this was the appropriate place.
const { error, fetchMore, data, loading } = useQuery(MyQuery, {
fetchPolicy: 'no-cache',
suspend: false,
ssr: false,
variables: {
cursor: '',
pageSize: pageSize,
search: '',
orderBy: orderBy
},
});
fetchMore({
query: MyQuery,
variables: {
cursor: endCursor,
pageSize: pageSize,
search: searchTerm,
orderby: orderBy,
},
updateQuery: (_, { fetchMoreResult }) => {
console.log('fetchMoreResult', fetchMoreResult)
return fetchMoreResult;
},
After the initial load, I search, then I change the page size. Now fetchMoreResult logs the correct response from the server, but data seems to be showing the initial response (which is not the response I requested).
from react-apollo-hooks.
I think the problem was that sometimes it was using the variables from fetchMore and sometimes it was using variables from useQuery. After I have them both use the same variables, the problem seemed to resolve itself. How do I know which variables are being applied, though?
from react-apollo-hooks.
Hi @trojanowski, in #15 you said you're gonna wait with its implementation until suspense for data fetching is released. According to the react roadmap that's not gonna happen before mid 2019. Any plans to release the other four PRs (especially #21 ) before that? That would be very helpful. Thank you
from react-apollo-hooks.
@schlesingermatthias all of those PRs are already released and available in the latest version.
from react-apollo-hooks.
I'm going to close this issue because IMO this library can be considered stable to use (in the non-suspense mode). I created a new meta issue with a list of breaking changes planned for the next version: #138.
from react-apollo-hooks.
Related Issues (20)
- Unable to Access Result Attributes
- Calling a mutation within React.useEffect causes infinite loop HOT 8
- Error on refetch
- Apollo client not handing Throw Error networkError eg.400,500
- data is no longer defined in 0.5.0 before data is loaded HOT 2
- Archive repo
- TypeError: Object(...) is not a function
- Question: How can I abort a query already in progress? HOT 1
- useLazyQuery ignores request if one is in progress (or how to cancel running requests)
- Support for `renderToStream`
- Correct network response but incorrect data object HOT 2
- Prevent infinite loop with useQuery
- Does useQuery hook uses local state for storing the data it receives from the server ?
- useSubscription - Duplicated subscription on page refresh HOT 1
- Refetching useQuery with skip: true results in a network request but does not update data
- Testing useSubscription and no responses when other mutations being mocked
- dynamic input variables in react-apollo-hooks
- Is it possible to map the result of one query to another query? HOT 1
- Is there any way to use multiple queries before a component render inside the component itself?
- UseQuery is not calling any API in the network side, when I console.log response, I am seeing this. what could be wrong here?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-apollo-hooks.