apollo-client

AWS AppSync query returns cached response even when offline is disabled

最后都变了- 提交于 2021-02-19 02:52:19
问题 I have a fairly simple node app using AWS AppSync. I am able to run queries and mutations successfully but I've recently found that if I run a query twice I get the same response - even when I know that the back-end data has changed. In this particular case the query is backed by a lambda and in digging into it I've discovered that the query doesn't seem to be sent out on the network because the lambda is not triggered each time the query runs - just the first time. If I use the console to

Duplicate object types in Apollo GraphQL for Android

情到浓时终转凉″ 提交于 2021-02-18 21:58:50
问题 On my project GraphQL schema the object AllowedPeriod (it's just two fields startsAt/endsAt) can arrive inside different objects of the graph. When generating queries, apollo is creating a new type for every <parent_object>.AllowedPeriod For example, in the GetDevicesQuery , the AllowedPeriod can be inside devices , actions or group , hence generating the following classes. GetDevicesQuery.AllowedPeriod GetDevicesQuery.AllowedPeriod1 GetDevicesQuery.AllowedPeriod2 Is there a way to tell

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

Access to this.$apollo from Vuex store with vue-apollo in NUXT?

喜夏-厌秋 提交于 2021-02-10 13:59:45
问题 I want to store the user that comes from the login on an action in the vuex store. But there is no access to this.$apollo . export const actions = { UPSERT_USER({ commit }, { authUser, claims }) { this.$apollo .mutate({ mutation: UPSERT_USER_MUTATION, variables: { id: user.uid, email: user.email, name: user.name, picture: user.picture, }, }) } Thanks! 回答1: You should be able to access it like this: export default { actions: { foo (store, payload) { let client = this.app.apolloProvider

Apollo Client delete Item from cache

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-10 12:59:27
问题 Hy I'm using the Apollo Client with React. I query the posts with many different variables. So I have one post in different "caches". Now I want to delete a post. So I need to delete this specific post from all "caches". const client = new ApolloClient({ link: errorLink.concat(authLink.concat(httpLink)), cache: new InMemoryCache() }); Postquery: export const POSTS = gql` query posts( $after: String $orderBy: PostOrderByInput $tags: JSONObject $search: String $orderByTime: Int ) { posts( after

Apollo Client: retrieving the results from a query with errors

不问归期 提交于 2021-02-10 12:00:56
问题 I'm using the GraphQL Apollo Client. And I'm trying to retrieve the results from a query with errors. GraphQL response How do I retrieve the data, even when an error is returned in the same response? This automatically catches the error. Instead, I want it to access the data. this.client.query({ query: gql(query), variables: variables }).then(function ({ data }) { return data; }).catch(error => console.log(error)); Couldn't find anything in Apollo docs about this. Any ideas? 回答1: if you

Apollo Client: retrieving the results from a query with errors

夙愿已清 提交于 2021-02-10 11:57:12
问题 I'm using the GraphQL Apollo Client. And I'm trying to retrieve the results from a query with errors. GraphQL response How do I retrieve the data, even when an error is returned in the same response? This automatically catches the error. Instead, I want it to access the data. this.client.query({ query: gql(query), variables: variables }).then(function ({ data }) { return data; }).catch(error => console.log(error)); Couldn't find anything in Apollo docs about this. Any ideas? 回答1: if you

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