Questions tagged [apollo-link-state]

24 questions
12
votes
1 answer

How to deal with nested state in apollo-link-state (similar to Redux's combineReducers)

If we look at the todos example, imagine that the application had multiple views (a TodoList page and another page). So instead of "todos" directly referring to an array of todo items, at the top level of the state/store/cache it would actually…
Soren
  • 307
  • 1
  • 2
  • 11
2
votes
1 answer

Apollo Client State - object written to cache with writeData is missing

I have a problem with Apollo Client State in my React app. I'm creating my client state link in the following way: const stateLink = withClientState({ cache, defaults: { simulation: { __typename: 'Simulation', configurationName:…
mblichar
  • 23
  • 2
2
votes
1 answer

apollo-link-state add field with default value to type

Here's what I'm trying to accomplish: I have a graphql API endpoint that returns me a Project object like this(unrelated fields removed): { "data": { "Project": { "id": "cjp4b84wkochq0167gpu8oa7h", "requests": [ { …
2
votes
0 answers

Apollo react: combining rest and graphql with link-state

I am trying to use REST endpoints to post data and GraphQL for query and fetch along with apollo-link-state. My rest endpoint is getting hit and application is getting created. But when I try to run the query to write to cache it's not hitting the…
rak1n
  • 671
  • 1
  • 8
  • 17
1
vote
1 answer

Using TypeGraphQL to generate typedefs and resolvers for Apollo local state in browser

I would like to use TypeGraphQL with Apollo local state in browser. How can I use TypeGraphQL to generate typedefs and resolvers for Apollo local state in browser? I saw the browser shim but the purpose seems to ignore TypeGraphQL decorators in…
geeko
  • 2,649
  • 4
  • 32
  • 59
1
vote
0 answers

Could not find "client" in the context of ApolloConsumer

I am trying to implement react-apollo to store my local states, I can write to them using client.writeData() but when i try to access them, I keep getting errors I tried following…
Anita
  • 476
  • 3
  • 10
  • 24
1
vote
2 answers

I need to set my Apollo Client Cache to its defaults

I have a React app which is using Apollo Client. I'm using apollo-link-state and apollo-cache-persist and need to reset my store to its default values when client.resetStore() is called in my app. The docs say that when creating a client you should…
1
vote
1 answer

apollo-link-state defaults derived from query data?

Note: This is a followup question to my previous question about Apollo GraphQl Storing derived data I'm using apollo-link-state to store data that's derived from query data. In this example the query data from the db includes some (x,y) points on a…
Raychaser
  • 340
  • 2
  • 12
1
vote
1 answer

Simply watching/reading a value from Apollo cache

I am trying to perform what I believe is a simple task. I have a search box that is successfully using the client.writeQuery to add an item to the cache.It looks like this: client.writeQuery({ query: gql` { …
BehemothDan
  • 316
  • 3
  • 15
1
vote
1 answer

What are the eviction rule for apollo-cache-inmemory?

From what I understand, anything in cache is ephemeral and is subjected to some kind of eviction rule, like LRU. In this case, if we are using the in-memory cache and apollo-link-state to replace redux or vuex, how do we guarantee that some states…
Sam
  • 1,288
  • 1
  • 13
  • 22
1
vote
0 answers

Force re-render components after local store is updated from iframe

I am building a Shopify app with React and Apollo, using apollo-link-state to manage a local data store. Because of the way Shopify embedded apps are done, I end up updating the local data store from a modal, which is technically an iframe pointing…
Silvain
  • 399
  • 4
  • 20
0
votes
0 answers

apollo-link-state not practical with HUGE data sets

I'm trying to get this apollo-link-state to work for my app which relies on a tremendous amount of nested data. I went this route because front loading all that data takes 20seconds, can't have that. So, i figure to load the bare minimal, and then…
james emanon
  • 11,185
  • 11
  • 56
  • 97
0
votes
1 answer

apollo-state-link does not hold state in cache when page is refreshed

I noticed that when I update my cache locally on the clientside and it routes to another page, the cache persists with the data. However, when I refresh that page, the cache is cleared. Is there a way to keep the cache state even after refreshing?
Shaun Chua
  • 705
  • 3
  • 13
  • 32
0
votes
1 answer

apollo-link-state and how do I access the local state / cache?

Perhaps I am just not getting what apollo-link-state does, but I figured if I had a "default" value, THAT would show up in my props via the Provider. Yet, I can't locate it. How do you access the "cache" or local state? I have: import {…
james emanon
  • 11,185
  • 11
  • 56
  • 97
0
votes
1 answer

Does apollo local state update subscriber when data that is not being used is updated

Per the example in the doc of apollo-link-state, it states that Once you call client.writeData, the query result on the render prop function will automatically update Let's say we keep two variables foo and bar in apollo local cache. ComponentFoo…
1
2