apollo-client

Apollo Client Cache vs. Redux

橙三吉。 提交于 2020-08-19 06:07:43
问题 I'm trying to migrate from Redux Store to use Apollo Client Cache that comes with Apollo Graphql Client. One of the key features that sets Apollo Client apart from other data management solutions is its normalized cache . Just by setting up Apollo Client, you get an intelligent cache out of the box with no additional configuration required. With Redux we have to write actions, types and dispatch actions based on the response received from the side-effect and set the data in the store using

Apollo Client Cache vs. Redux

自作多情 提交于 2020-08-19 06:05:29
问题 I'm trying to migrate from Redux Store to use Apollo Client Cache that comes with Apollo Graphql Client. One of the key features that sets Apollo Client apart from other data management solutions is its normalized cache . Just by setting up Apollo Client, you get an intelligent cache out of the box with no additional configuration required. With Redux we have to write actions, types and dispatch actions based on the response received from the side-effect and set the data in the store using

How can I know the networkStatus of all queries in ApolloClient globally?

大城市里の小女人 提交于 2020-07-21 07:03:44
问题 I am trying to show preloader when a networkStatus is in-flight. I know that every query returns its own networkStatus, but in my application there are so many different queries. I want to have a way of handling all the networkStatus for all the queries, globally. What I'm wanting to know inside my code is the answer for: "Is there any query pending on the network?". 回答1: Currently, there's no way of doing that, at least not easily/built-in. You could request this as a feature on https:/

How can I know the networkStatus of all queries in ApolloClient globally?

牧云@^-^@ 提交于 2020-07-21 07:03:25
问题 I am trying to show preloader when a networkStatus is in-flight. I know that every query returns its own networkStatus, but in my application there are so many different queries. I want to have a way of handling all the networkStatus for all the queries, globally. What I'm wanting to know inside my code is the answer for: "Is there any query pending on the network?". 回答1: Currently, there's no way of doing that, at least not easily/built-in. You could request this as a feature on https:/

how to unsubscribe with useQuery and subscribeToMore

浪尽此生 提交于 2020-07-18 05:05:44
问题 Another post shared an example of how to unsubscribe, where the Apollo docs don't. The Apollo docs do mention what subscribeToMore returns... subscribeToMore : A function that sets up a subscription. subscribeToMore returns a function that you can use to unsubscribe. This does give a hint. It would help to see an example. the question Using @apollo/react-hooks , inside of a useEffect() and returning the results of the subscribeToMore , is this the way to unsubscribe on a component unmount?

how to unsubscribe with useQuery and subscribeToMore

≯℡__Kan透↙ 提交于 2020-07-18 05:05:06
问题 Another post shared an example of how to unsubscribe, where the Apollo docs don't. The Apollo docs do mention what subscribeToMore returns... subscribeToMore : A function that sets up a subscription. subscribeToMore returns a function that you can use to unsubscribe. This does give a hint. It would help to see an example. the question Using @apollo/react-hooks , inside of a useEffect() and returning the results of the subscribeToMore , is this the way to unsubscribe on a component unmount?

Apollo Queries triggered and causing rerendering in useContext on URL Change

我怕爱的太早我们不能终老 提交于 2020-07-10 10:28:39
问题 GIF of Rerender occuring I'm not sure how to proceed. As you can see, the Header's state (as passed down via context) is switching from the user's data --> undefined --> same user's data. This occurs every time there's a url change, and doesn't happen when I do things that don't change the url (like opening the cart for example). Is this expected behaviour? Is there any way I can get the query in my context to only be called when there is no user data or when the user data changes? I tried

Expose HTTP GET API in GraphQL Apollo Server v2.0

我们两清 提交于 2020-07-10 10:26:43
问题 I am using Apollo Server v2.0 (without middleware) as part of my project and I would like to add support for a HTTP GET endpoint to for file downloads. Is there a way to expose an API endpoint without using apollo-server-express? Thank you 回答1: No. While apollo-server currently uses express under the hood, the Express instance is not exposed as a property on the ApolloServer instance. In order to expose any additional endpoints, you'd need to migrate to apollo-server-express or any of the

Apollo GraphQL (React) Data sharing across components

♀尐吖头ヾ 提交于 2020-06-14 07:46:47
问题 I just started using react-apollo and was wondering what was the best way to share data across components. For example, I have componentA which is using grapql from react-apollo to fetch some data ( WrappedA ). I also have some other component, componentB , somewhere else in my UI and want to use the data already fetched by componentA . Attached a very simple example below. const ComponentA = ({ ...props }) => ( <div> ComponentA... id: {props.organisationsData.organisations.id} </div> ) const