react-apollo

Reach child does not update when state changes

佐手、 提交于 2019-12-24 07:51:54
问题 I have created a code snippet to demonstrate the issue: https://codesandbox.io/s/o1v4qxw3yy Essentially the checkedValues (an array of ids) does not get passed to the ChildComponent when a checkbox is clicked. Unless I send another variable along with it. If you uncomment the cat line @32 in the ParentComponent, it all starts working. I have noticed that the Apollo HOC around the ChildComponent receives the new value live , but the ChildComponent does not update unless another state change is

how to set many-to-many relation in graphql mutation?

最后都变了- 提交于 2019-12-23 10:53:20
问题 I may be missing something, but can not find any information on Apollo docs about the way to set a many-to-many relation when creating a new entry. When the relation is one-to-many it is as simple as setting the ID of the one-side of the relationship in the many-side object. But let's pretend I am working with Books and Authors, how would I write a graphql query that creates a Book for one (or many?) Authors? 回答1: This should probably happen at the API layer on the GraphQL server (i.e. schema

How to create nested nodes in one mutation?

浪尽此生 提交于 2019-12-23 09:57:07
问题 Hi I am trying to write data on my https://www.graph.cool/ db with a mutation. My project is a React web-app and I am using Apollo as graphql client and graphql-tag npm package as template literal parser. The problem is that i don't know how to arrange the gql template string for the correct mutation with nested data. My schema looks like this, for example note the field "Addresses" for the type "Company" is an array of "Address" objects type. type Company { name: String! website: String

How to create nested nodes in one mutation?

≡放荡痞女 提交于 2019-12-23 09:55:47
问题 Hi I am trying to write data on my https://www.graph.cool/ db with a mutation. My project is a React web-app and I am using Apollo as graphql client and graphql-tag npm package as template literal parser. The problem is that i don't know how to arrange the gql template string for the correct mutation with nested data. My schema looks like this, for example note the field "Addresses" for the type "Company" is an array of "Address" objects type. type Company { name: String! website: String

Could not find “client” in the context of Query or as passed props

孤人 提交于 2019-12-23 03:25:34
问题 This is how I'm trying to implement apollo graphQL in my react native application. But with that I do get the error Could not find "client" in the context of Query or as passed props. Wrap the root component in an <ApolloProvider> So I thought I have done exactly this, but obviously I'm missunderstanding something. import React, { Component } from 'react' import { ApolloProvider, graphql } from 'react-apollo' import { ApolloClient } from 'apollo-client' import { createHttpLink } from 'apollo

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

佐手、 提交于 2019-12-23 02:44:29
问题 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}>

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

青春壹個敷衍的年華 提交于 2019-12-23 02:44:06
问题 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}>

Apollo updateQueries Not Called?

孤街浪徒 提交于 2019-12-22 14:59:48
问题 I'm studying Apollo pub-sub in GitHunt-React and GitHunt-API. When I run those apps and enter a new comment, the comment is saved by the call to submit, and then the updateQueries codeblock runs here: const CommentsPageWithMutations = graphql(SUBMIT_COMMENT_MUTATION, { props({ ownProps, mutate }) { console.log('in CommentsPageWithMutations'); return { submit({ repoFullName, commentContent }) { <==RUNS THE MUTATION debugger; return mutate({ variables: { repoFullName, commentContent },

How to get updated data from apollo cache

空扰寡人 提交于 2019-12-22 08:17:46
问题 Does Apollo client have some sort of thing like mapStateToProps (Redux)? let's say I have a component, after query I know there's data in the cache so I do something like: class Container extends React.Component { ... ... render() { const notes = this.props.client.readFragment(NOTES_FRAGMENT) // notes has everything I need return (<Child notes={notes} />); } } export default WithApollo(Container); However when I have a sibling component which calls mutation and do update, the <Child />

Graphql, react-apollo how to transfer variable to query at loading component state

ぃ、小莉子 提交于 2019-12-22 05:43:15
问题 I have a simple react component that must load data from server when user ask it. Problem is that i don't know how to transfer dynamic variable speakerUrl and access it in before component load state. Sure i can access it from this.props.params , but component is not loaded and i can't access it when i make a graphql query. Query - QuerySpeaker is working fine when i manualy set url variable. Router <Route path="/speaker/:speakerUrl" component={SpeakerPage} /> Component - SpeakerPage import