react-apollo

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

佐手、 提交于 2021-02-10 08:31:50
问题 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

JS TypeError: Cannot Read Property “…” of Undefined, Despite DATA being returned?

被刻印的时光 ゝ 提交于 2021-02-08 10:19:01
问题 I am following this Apollo Pagination tutorial: Apollo Pagination Examples Summary of my issue: I have a known working GraphQL query that works in the playground. When I try to fetch data and use it in a React component, as outlined in that Apollo link above, I get the following error: "TypeError: Cannot read property 'errorlogsConnection' of undefined" However, when I check the response from the graphQL api in the web console, the query does in fact return data. Picture attached below. I

How to force Apollo Client to use cached data

谁都会走 提交于 2021-02-08 07:52:37
问题 We have an application that initially load a list of widgets: query Widgets() { widgets() { ...Widgets } } fragment Widgets on Widgets { name description rootWidget widgets { ...WidgetInterface } } fragment WidgetInterface on WidgetInterface { id name description type } later on I render this widgets, where every react component is wrapped with another graphql call to get the data for a single widget. As we fetch this data initially I would expect apollo get the data from local store, but it

Apollo GraphQl react. How to clear query cache for all variable combinations?

大兔子大兔子 提交于 2021-02-06 14:59:17
问题 I am using apollo graphql in my react application. Say I have the following query: query ListQuery($filter: String!) { items(filter: $filter) { id name } } This query lets me query a list of items using a filter. Say I used filter string A, and then used filter string B. The cache would now contain two entries: ListQuery(A) and ListQuery(B). Now let's say I use a mutation to add a new item. How can I remove all the cached queries from the cache? So in this case, I want to remove both

Multiple Queries/Mutation in Apollo 2.1

心不动则不痛 提交于 2021-02-06 08:46:57
问题 I need some help using the new Query and Mutation component in Apollo 2.1, especially with multiple queries and mutations. I have the following problems: I have a graphql request that depends on a previous graphql result, how can I deal with this? How do I add two different mutations (in my component I need to do two different actions) in a component that already has a query? 回答1: edit 2019/08/24 from the Apollo docs: The new hooks API for Apollo Client is a simpler way to fetch data in your

Multiple Queries/Mutation in Apollo 2.1

点点圈 提交于 2021-02-06 08:45:51
问题 I need some help using the new Query and Mutation component in Apollo 2.1, especially with multiple queries and mutations. I have the following problems: I have a graphql request that depends on a previous graphql result, how can I deal with this? How do I add two different mutations (in my component I need to do two different actions) in a component that already has a query? 回答1: edit 2019/08/24 from the Apollo docs: The new hooks API for Apollo Client is a simpler way to fetch data in your

GraphQL - Execute sub query conditionally

故事扮演 提交于 2021-01-29 04:01:33
问题 I'm trying to optimise the query executed by some of my react components that are shared across the whole app, such as Footer and Header components. I'm trying not to fetch the Student Solution details when the variable institutionPath is not provided. query organisationAndInstitution($organisationName: String!, $institutionPath: String!, $fetchInstitution: Boolean!){ organisation(where: { name: $organisationName }){ name } studentSolutionRelationships(where:{ AND: [ { status: PUBLISHED }, {

Query works in GraphiQL but returns empty array in Actual Code while using React Apollo

荒凉一梦 提交于 2021-01-28 21:51:07
问题 I have a simple query like this import gql from "graphql-tag"; export const GET_TODOS_BY_PRODUCT = gql` query getTodosByProduct( $id: ID! $completed: Boolean = false $limit: Int = 100 ) { product(id: $id) { hashtag todos(completed: $completed, limit: $limit) { body } } } `; In GraphiQL, it returns results like - { "data": { "product": { "todos": [ { "body": "Remove Custom Font from Tweet #a2k", "product": { "id": "1439" }, "__typename": "Todo" }, { "body": "Make Site a PWA #a2k", "product": {

Query works in GraphiQL but returns empty array in Actual Code while using React Apollo

跟風遠走 提交于 2021-01-28 21:24:56
问题 I have a simple query like this import gql from "graphql-tag"; export const GET_TODOS_BY_PRODUCT = gql` query getTodosByProduct( $id: ID! $completed: Boolean = false $limit: Int = 100 ) { product(id: $id) { hashtag todos(completed: $completed, limit: $limit) { body } } } `; In GraphiQL, it returns results like - { "data": { "product": { "todos": [ { "body": "Remove Custom Font from Tweet #a2k", "product": { "id": "1439" }, "__typename": "Todo" }, { "body": "Make Site a PWA #a2k", "product": {

React apollo not update data after mutation

我只是一个虾纸丫 提交于 2021-01-28 08:08:16
问题 I have user and user update form, but the problem is that user data in a web app is not updated after mutation. mutation: mutation UserUpdate($user: UserUpdateInput!, $id: String!) { userUpdate(user: $user, id: $id) { id } } query: query UsersItemQuery($id: String!) { userById(id: $id) { id email datetime firstName lastName middleName phone role podcasts { id title } } } I use it on my UserItem.tsx component: const usersItem = useQuery<UsersItemQuery, UsersItemQueryVariables>(usersItemQuery,