react-apollo

compose not exported from react-apollo

佐手、 提交于 2021-02-18 22:15:26
问题 I'm following a graphql tutorial on youtube (https://www.youtube.com/watch?v=ed8SzALpx1Q at about 3hr 16min) and part of it uses compose from "react-apollo". However, I'm getting an error because the new version of react-apollo does not export this. I read online that I need to replace import { compose } from "react-apollo" with import { compose } from "recompose" but doing that produces the error TypeError: Cannot read property 'loading' of undefined I've also read that I should replace the

React-router-dom not re rendering Switch when state is change

自作多情 提交于 2021-02-11 17:05:29
问题 I am using aws-amplify, react-hook in my project. The app have some private Routes has been define below: const ProtectedRoute = ({render: C, props: childProps, ...rest}) => { return ( <Route {...rest} render={rProps => (childProps) ? ( <C {...rProps} {...childProps} /> ) : ( <Redirect to={`/login?redirect=${rProps.location.pathname}${ rProps.location.search }`} /> ) } /> ); } In App.js, we change childProps to define whether user is login or not. But when childProps change, Switch not re

React-router-dom not re rendering Switch when state is change

让人想犯罪 __ 提交于 2021-02-11 17:04:26
问题 I am using aws-amplify, react-hook in my project. The app have some private Routes has been define below: const ProtectedRoute = ({render: C, props: childProps, ...rest}) => { return ( <Route {...rest} render={rProps => (childProps) ? ( <C {...rProps} {...childProps} /> ) : ( <Redirect to={`/login?redirect=${rProps.location.pathname}${ rProps.location.search }`} /> ) } /> ); } In App.js, we change childProps to define whether user is login or not. But when childProps change, Switch not re

How to store the data in React state after Querying it from GraphQL?

ⅰ亾dé卋堺 提交于 2021-02-11 15:51:19
问题 Following is my Query: import React from 'react'; import getProducts from '../queries/getProduct'; import { Query } from "react-apollo"; export const Product = () => { const proId = { "productId": "95eb601f2d13" } return ( <Query query={getProducts} variables={proId}> {({ loading, error, data }) => { if (loading) return "Loading..."; if (error) return `Error! ${error.message}`; return ( <div> {data.map(entry => entry)} </div> ); }} </Query> ); }; export default Product; I need to now store

How to store the data in React state after Querying it from GraphQL?

坚强是说给别人听的谎言 提交于 2021-02-11 15:49:08
问题 Following is my Query: import React from 'react'; import getProducts from '../queries/getProduct'; import { Query } from "react-apollo"; export const Product = () => { const proId = { "productId": "95eb601f2d13" } return ( <Query query={getProducts} variables={proId}> {({ loading, error, data }) => { if (loading) return "Loading..."; if (error) return `Error! ${error.message}`; return ( <div> {data.map(entry => entry)} </div> ); }} </Query> ); }; export default Product; I need to now store

How to store the data in React state after Querying it from GraphQL?

牧云@^-^@ 提交于 2021-02-11 15:48:50
问题 Following is my Query: import React from 'react'; import getProducts from '../queries/getProduct'; import { Query } from "react-apollo"; export const Product = () => { const proId = { "productId": "95eb601f2d13" } return ( <Query query={getProducts} variables={proId}> {({ loading, error, data }) => { if (loading) return "Loading..."; if (error) return `Error! ${error.message}`; return ( <div> {data.map(entry => entry)} </div> ); }} </Query> ); }; export default Product; I need to now store

How to access current_user with devise-token_authenticatable gem?

孤街浪徒 提交于 2021-02-11 15:27:16
问题 I’m working on a small project that is using devise and devise-token_authenticatable in a Rails/GraphQL/Apollo/React setup. Project is setup using webpacker , so the front and back ends are both served from the same domain. Sign-in, register, log-out are all handle by the front end (React). I also need to point out this is not an API only app. It seems, server is not setting the current_user or the proper cookie and I’m getting a network error. Heroku logs shows the following error:

How to access current_user with devise-token_authenticatable gem?

可紊 提交于 2021-02-11 15:26:26
问题 I’m working on a small project that is using devise and devise-token_authenticatable in a Rails/GraphQL/Apollo/React setup. Project is setup using webpacker , so the front and back ends are both served from the same domain. Sign-in, register, log-out are all handle by the front end (React). I also need to point out this is not an API only app. It seems, server is not setting the current_user or the proper cookie and I’m getting a network error. Heroku logs shows the following error:

Compatibility between cypress and react-apollo

人走茶凉 提交于 2021-02-10 14:22:59
问题 I am using react-apollo to make GraphQL queries, and I am using Cypress for testing. The problem is that these 2 dont seem to play well along. Apollo seems to be making all its requests through the Fetch API. But Cypress seems like it is not able to capture anything, except XHR requests. So what could I do to solve this problem? Is there a way for Cypress to capture "fetch" requests? Is there a way for react-apollo to use "xhr" instead of "fetch"? 回答1: Try out cypress-graphql-mock You just

React Uncaught Invariant Violation: Could not find “client” in the context of ApolloConsumer. Wrap the root component in an <ApolloProvider>

不想你离开。 提交于 2021-02-10 08:32:03
问题 I have a React app using react-apollo:2.5.8 and a library of custom components that I install via NPM and use within the app. The library has react-apollo:2.5.8 listed in peer and dev dependencies. Ever since I upgraded react-apollo to 2.5.8 I have been getting this error `Uncaught Invariant Violation: Could not find "client" in the context of ApolloConsumer. Wrap the root component in an <ApolloProvider>.` I tried listing React-apollo within externals in the Webpack build for the library as