react-apollo

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:/

react-apollo: Long running mutation appears to be retried after 2 minutes

你。 提交于 2020-07-09 07:48:05
问题 I have a long running import script (~4 minutes) which is kicked off with a graphql mutation. Logging on the server, I've noticed that exactly 2 minutes after I trigger the mutation, it gets retried, causing the import to be run twice. I guess this is caused by some functionality in apollo-link but I've had a look through the code there and can't find an option to turn it off. Here is how I've set up apollo: import ApolloClient from 'apollo-client' import { ApolloLink } from 'apollo-link'

Upload image to GraphQL server

萝らか妹 提交于 2020-07-07 04:09:35
问题 I'm using react-dropzone and graphql-server-express-upload to upload an image all in GraphQL Apollo. In my client the file looks like this: But in the server, when I log it, it looks like this: { preview: 'blob:http://localhost:3000/c622b0bd-3f0d-4f52-91f4-7676c8534c59' } I'm following the instructions in the readme in graphql-server-express-upload, but no luck so far. How do I get the full image? 回答1: I ended up using apollo-upload-client, works great! 回答2: A different approach is to convert

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

use query hook react Apollo conditional call

∥☆過路亽.° 提交于 2020-06-11 21:23:31
问题 I have been using react-apollo and the render prop approach. This worked perfectly and my code looked something like this. const App = () => { const [player, setPlayer] = React.useState(null); if (player) { return ( <GetBroncosPlayerQuery variables={{ player }}> {({ data }) => { // do stuff here with a select box }} </GetBroncosPlayersQuery> ) } } Now, if I try doing the same with the useQuery hook I get the following error, when my code looks like this: const App = () => { const [player,

Custom ApolloProvider for access to React Context inside

烈酒焚心 提交于 2020-06-01 05:08:40
问题 I created ApolloCustomProvider because I want to use addNotification function from my AppContext for graphQL error handling. The problem is that this custom provider seems to work while querying or mutating API but errorLink 's functions like addNotification and console.log() doesn't work. Also console.log() from request function doesn't print anything. But when I put everything from ApolloCustomProvider to standard TypeScript file (.ts - not React Component) and then use it like: import {

Apollo react hooks array object mutation

北城余情 提交于 2020-06-01 04:44:21
问题 So I am doing a MARN stack using MongoDB, Apollo, React Native (Expo) and Node I am stuck trying to figure out how to upload an array of object. i.e A post with an array of shots It is all working fine in the Apollo playground with this: mutation createPost { createPost( input: { shots: [ { title: "Test test test" content: "Test test test" image: "https://source.unsplash.com/random/768x768" } { title: "Best best best" content: "Test test test" image: "https://source.unsplash.com/random