apollo-client

How do I update the Apollo data store/cache from a mutation query, the update option doesn't seem to trigger

℡╲_俬逩灬. 提交于 2019-12-07 13:51:31
问题 I have a higher order component in my react native application that retrieves a Profile. When I call an "add follower" mutation, I want it to update the Profile to reflect the new follower in it's followers collection. How do I trigger the update to the store manually. I could refetch the entire profile object but would prefer to just do the insertion client-side without a network refetch. Currently, when I trigger the mutation, the Profile doesn't reflect the change in the screen. It looks

Reactjs/Apollo/AppSync Mutation triggered twice

落花浮王杯 提交于 2019-12-07 03:45:27
I'm having an issue with React/Apollo/AppSync with mutations triggering twice (or more). I have a React app that has an update mutation triggered by the usual UI button onClick. <button className={`btn btn-sm`} onClick={(event) => { that.toggleSubscription(event, subscriptionid, serviceid, status); }}> <i className={`fas ${icon} fa-fw`} /> {title} </button> The toggleSubscription function looks like this: toggleSubscription = async (event, subscriptionid, serviceid, currentStatus) => { event.preventDefault(); event.stopPropagation(); if (currentStatus === "mandatory") return; console.log

GraphQL Query Runs Sucessfully One Time and Fails To Run Again using Apollo and AWS AppSync

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-06 15:51:54
I'm using the basic client configuration from the example on the first page of https://github.com/awslabs/aws-mobile-appsync-sdk-js repo: const client = new AWSAppSyncClient({ url: appSyncConfig.graphqlEndpoint, region: appSyncConfig.region, auth: { type: appSyncConfig.authenticationType, apiKey: appSyncConfig.apiKey, } }); But without the <Rehydrated> component, and with a Redux <Provider> component. The highest level parent component is wrapped like this: <Provider store={store}> <ApolloProvider client={client}> <App/> </ApolloProvider> </Provider> I've tried swapping the order for the

Dynamic mutation document for react-apollo

与世无争的帅哥 提交于 2019-12-06 09:28:50
问题 I need to change my mutation document dynamically to be able to create multiple items in a single mutation. So I have this function createOrderName that takes an integer and be able to create the correct mutation document. Eg. createOrderName(2) gets mutation createOrderMut($input0: AddToOrderMenuItemConnectionInput!, $input1: AddToOrderMenuItemConnectionInput!) { input0: addToOrderMenuItemConnection (input:$input0) { changedOrderMenuItem { id } } input1: addToOrderMenuItemConnection (input:

Apollo readQuery Fails Even Though Target Object is Present?

岁酱吖の 提交于 2019-12-06 07:04:38
I'm working on a call to readQuery. I'm getting an error message: modules.js?hash=2d0033b4773d9cb6f118946043f7a3d4385825fe:25847 Error: Can't find field resolutions({"id":"Resolution:DHSzPa8bvPCDjuAac"}) on object (ROOT_QUERY) { "resolutions": [ { "type": "id", "id": "Resolution:AepgCCio9KWGkwyMC", "generated": false }, { "type": "id", "id": "Resolution:DHSzPa8bvPCDjuAac", // <==ID I'M SEEKING "generated": false } ], "user": { "type": "id", "id": "User:WWv57KsvqWeAoBNHY", "generated": false } }. The object with that id appears to be plainly visible as the second entry in the list of

How to set up Apollo client only after user authenticates?

倖福魔咒の 提交于 2019-12-06 05:44:49
问题 I'm a bit confused on how to structure my React/GraphQL (Apollo) app when no connection should be made until the user authenticates/logs in. Currently I have this: class App extends Component { render() { return ( <ApolloProvider client={client}> <Provider store={store}> <Router> <div> <ul> <li><Link to="/">Home</Link></li> <li><Link to="/login">Log In</Link></li> <li><Link to="/signup">Sign Up</Link></li> </ul> <AuthenticatedRoute exact path="/" component={HomePage} /> <Route path="/login"

How to write to apollo cache from within React component with out losing context of “this”

拜拜、爱过 提交于 2019-12-06 03:42:17
I'm having trouble trying to read from apollo cache from within a react component the mutation works and writes to my server and returns the data but when passed to my update function it seems to lose the context of this when in inMemoryCache.js "apollo-cache-inmemory": "^1.2.5" "react-apollo": "^2.1.4" "apollo-boost": "^0.1.7" TypeError: Cannot read property 'read' of undefined at ./node_modules/apollo-cache-inmemory/lib/inMemoryCache.js.InMemoryCache.readQuery import React, { Component } from "react"; import { graphql } from "react-apollo"; import trim from "lodash/trim"; import AuthorForm

React Apollo 2 with React Router. graphql HOC loading: true forever if I navigate

大憨熊 提交于 2019-12-06 02:15:32
This is the code: https://codesandbox.io/s/p90q6674qq I simply use: export default graphql(CURRENT_USER_QUERY)(Menu); on the Menu component and simply this code in App component: class App extends Component { render() { return ( <div> {/* <Menu /> */} <Route component={Menu} /> <Route exact path="/" component={Home} /> <Route path="/login" component={Login} /> </div> ); } } A bug? Where am I wrong? 来源: https://stackoverflow.com/questions/47733633/react-apollo-2-with-react-router-graphql-hoc-loading-true-forever-if-i-navigat

How do I update the Apollo data store/cache from a mutation query, the update option doesn't seem to trigger

此生再无相见时 提交于 2019-12-05 22:44:21
I have a higher order component in my react native application that retrieves a Profile. When I call an "add follower" mutation, I want it to update the Profile to reflect the new follower in it's followers collection. How do I trigger the update to the store manually. I could refetch the entire profile object but would prefer to just do the insertion client-side without a network refetch. Currently, when I trigger the mutation, the Profile doesn't reflect the change in the screen. It looks like I should be using the update option but it doesn't seem to work for me with my named mutations.

How to configure Graphene-Django to work with persisted queries?

ぃ、小莉子 提交于 2019-12-05 02:37:01
问题 It looks like my company is going to move forward with Persisted Queries from the Apollo Client, as is discussed here: https://dev-blog.apollodata.com/persisted-graphql-queries-with-apollo-client-119fd7e6bba5 In this article there is mention that something needs to be done to the Middleware on the server. I have been unable to find any information as to what needs to be changed with Graphene-Django. Can anyone provide any advice? Robert 回答1: Persisted queries are not a part of the GraphQL