Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Support for Apollo 3.0 beta #317

Closed
wtrocki opened this issue Oct 30, 2019 · 14 comments
Closed

Test Support for Apollo 3.0 beta #317

wtrocki opened this issue Oct 30, 2019 · 14 comments
Assignees

Comments

@wtrocki
Copy link
Collaborator

wtrocki commented Oct 30, 2019

As in topic new Apollo client exists as a single package with embedded cache

@wtrocki wtrocki self-assigned this Oct 30, 2019
@wtrocki wtrocki changed the title Support for Apollo 3.0 beta Test Support for Apollo 3.0 beta Oct 30, 2019
@wtrocki
Copy link
Collaborator Author

wtrocki commented Nov 1, 2019

Apollo-Cache-Persist works quite nicely with the beta Apollo 3.0 after changing imports.
Leaving open to monitor the next releases.

CC @benjamn

@dcecile
Copy link

dcecile commented Nov 14, 2019

3.0 doesn't have defaults anymore, only the writeData API. What's the best way to do "write data only once if not yet persisted"?

@wtrocki
Copy link
Collaborator Author

wtrocki commented Nov 14, 2019

@dcecile Can you clarify this better. I would recommend to drop some separate issue if you have it running with 3.0

@dcecile
Copy link

dcecile commented Nov 14, 2019

@wtrocki No problem, I've tried to clarify this in #320

@tylerjbainbridge
Copy link

Hi @wtrocki- can you clarify which imports (related to this package) need to be updated? I'm in the process of updating to apollo 3.0 and having some trouble.

Apollo-Cache-Persist works quite nicely with the beta Apollo 3.0 after changing imports.

@wtrocki
Copy link
Collaborator Author

wtrocki commented Mar 1, 2020

This information is outdated. In latest beta there is common package that should be used along with the cache interface. I have stopped looking into betas and waiting for some solid release to get things updated.

@goofiw
Copy link

goofiw commented Jul 14, 2020

3.0 released today, has anyone tried spinning this up?

@Titozzz
Copy link
Contributor

Titozzz commented Jul 15, 2020

I'm trying to update, persist cache complains about the missing writeData API. Currently investigating whether this is fully breaking or not.

@Titozzz
Copy link
Contributor

Titozzz commented Jul 16, 2020

I've checked writeApi is not used in apollo-cache-persist and proceeded to @ts-expect-error for now. No issues YET.

@darrylyoung
Copy link

Thanks, @Titozzz. Glad to hear you're having no issues. Has anyone else tried this with Apollo Client 3.x yet? I'm planning on migrating to 3.0 this week and wondered what I'm in for regarding this package. 😄

@alessandro-bottamedi
Copy link

I'm using apollo-cache-persist since Apollo client Beta 35, no issues! 😄😄

@robertvorthman
Copy link

Here is an example of how I am using apollo-cache-persist with @apollo/client 3.0.2 in my web app.

import React from 'react';
import { useEffect, useState } from 'react';
import { ApolloProvider } from '@apollo/client';
import { persistCache } from 'apollo-cache-persist';

//import a configured ApolloClient and InMemoryCache object
import client, { cache } from './client';

export default function ApolloProviderPersisted(props) {

  const [isPersisted, setIsPersisted] = useState();

  useEffect(() => {

    async function hydrate() {
      await persistCache({
        cache,
        storage: window.localStorage
      });
      setIsPersisted(true);
    }

    hydrate();

  }, []);

  if (!isPersisted) {
    //persistGate prop is a React component that displays a loading placeholder
    return props.persistGate || null;
  }

  return <ApolloProvider client={client}>{props.children}</ApolloProvider>

};

@punksta
Copy link

punksta commented Aug 10, 2020

There are typescript problems due to changes in imports.

node_modules/apollo-cache-persist/Cache.d.ts:1:29 - error TS2307: Cannot find module 'apollo-cache' or its corresponding type declarations.

1 import { ApolloCache } from 'apollo-cache';
                              ~~~~~~~~~~~~~~

node_modules/apollo-cache-persist/types/index.d.ts:1:29 - error TS2307: Cannot find module 'apollo-cache' or its corresponding type declarations.

1 import { ApolloCache } from 'apollo-cache';
                              ~~~~~~~~~~~~~~
 "@apollo/client": "^3.1.3",
 "apollo-cache-persist": "^0.1.1",

patch-package fix

diff --git a/node_modules/apollo-cache-persist/Cache.d.ts b/node_modules/apollo-cache-persist/Cache.d.ts
index 9387aa7..04c6554 100644
--- a/node_modules/apollo-cache-persist/Cache.d.ts
+++ b/node_modules/apollo-cache-persist/Cache.d.ts
@@ -1,4 +1,4 @@
-import { ApolloCache } from 'apollo-cache';
+import { ApolloCache } from '@apollo/client';
 import { ApolloPersistOptions, PersistedData } from './types';
 export default class Cache<T> {
     cache: ApolloCache<T>;
diff --git a/node_modules/apollo-cache-persist/types/index.d.ts b/node_modules/apollo-cache-persist/types/index.d.ts
index d22f69f..fdc121a 100644
--- a/node_modules/apollo-cache-persist/types/index.d.ts
+++ b/node_modules/apollo-cache-persist/types/index.d.ts
@@ -1,4 +1,4 @@
-import { ApolloCache } from 'apollo-cache';
+import { ApolloCache } from '@apollo/client';
 export declare type LogLevel = 'log' | 'warn' | 'error';
 export declare type LogLine = [LogLevel, any[]];
 export declare type TriggerUninstallFunction = () => void;

@wtrocki
Copy link
Collaborator Author

wtrocki commented Sep 26, 2020

Support landed in master. Working on releasing this

@wtrocki wtrocki closed this as completed Sep 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants