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

source.getRecordIDs is not a function #28

Closed
matt-dalton opened this issue Oct 17, 2019 · 9 comments
Closed

source.getRecordIDs is not a function #28

matt-dalton opened this issue Oct 17, 2019 · 9 comments
Labels
bug Something isn't working

Comments

@matt-dalton
Copy link

Thanks for the amazing lib!

I've just tried upgrading from 0.10.0 -> 0.11.1. I'm using react-relay 5.0.0.

I'm now getting an error:

source.getRecordIDs is not a function

From RelayModernStore.

Any idea what this could be?

@sibelius sibelius added the bug Something isn't working label Oct 17, 2019
@morrys
Copy link
Owner

morrys commented Oct 17, 2019

I make a small premise:

react-relay-offline uses these libraries to manage the offline:

  • wora/cache-persist
    • manages the status and its persistence in the storage
  • wora/netinfo
    • manages the network status detection
  • wora/offline-first
    • manages all the offline workflow with queuing requests
  • wora/relay-store
    • extension of the Store and Recordsource objects with the integration of wora/cache-persist + TTL
  • wora/relay-offline
    • extension of the relay environment with the integration of the wora/offline-first library

In the 0.11.0 release I upgraded the library that manages the relay cache.
Being one of the most important libraries in the offline context, I took the opportunity to update also the wora / relay-store where I modified the Store costructor. This for three main reasons:

  • be aligned with the react-relay Store constructor
  • make it clearer that the Store and RecordSource have two distinct persistence managements
  • first step to support react-relay v6.0.0

I recommend following the repository wora for any details.

https://github.com/morrys/wora/releases/tag/cache-persist%402.0.0

  • wora/relay-store

before

import { Store } from '@wora/relay-store';
const defaultTTL: number = 10 * 60 * 1000, 
const persistOptions: CacheOptions = {}; 
const persistOptionsRecords: CacheOptions = {}; 
const store = new Store(defaultTTL, persistOptions, persistOptionsRecords);

after

import { RecordSource, Store } from '@wora/relay-store';
import { CacheOptions } from "@wora/cache-persist";
const persistOptions: CacheOptions = {
    defaultTTL
}; 
const persistOptionsRecords: CacheOptions = {}; 
const recordSource = new RecordSource(persistOptionsRecords);
const store = new Store(recordSource, persistOptions);
  • wora/relay-offline
    • modified EnvironmentIDB.create signature

@morrys
Copy link
Owner

morrys commented Oct 17, 2019

I recommend using ~ and not ^ in the react-relay-offline version and follow this repository for any update :)

@morrys
Copy link
Owner

morrys commented Oct 17, 2019

I created this issue #27 to collect all your questions and then publish them as documentation.

@matt-dalton
Copy link
Author

matt-dalton commented Oct 18, 2019 via email

@morrys
Copy link
Owner

morrys commented Oct 18, 2019

I'm sorry, I'll explain better, in version 0.11.0 I released the dependency update then the breaking change in creating the store
as written in the previous comment.
Did you make that change?

@matt-dalton
Copy link
Author

Ahh right. Yes I was upgrading to react-relay-offline to 0.11.1 (explained in the initial comment). I don't install relay-store or cache-persist directly - should I be doing?

@morrys
Copy link
Owner

morrys commented Oct 21, 2019

Hi @matt-dalton,
you need to change the environment creation:
this is an example of how it should be:

import {Store, Environment, RecordSource} from 'react-relay-offline';
const persistRecordOptions = {};
const recordSource = new RecordSource(persistRecordOptions);
const persistStoreOptions = {};
const store = new Store(recordSource, persistStoreOptions);
const environment = new Environment({ network, store, }, offlineOptions);

If you are in doubt, please share your environment creation code with me.

@matt-dalton
Copy link
Author

Ahhh perfect - works. Sorry for being slow!

@morrys
Copy link
Owner

morrys commented Oct 21, 2019

do not worry :)

I admit that my documentation has to be improved but the 6.0.0 relay support and some optimizations are committing me to 100% :/

So for any information, open an issue :)

@morrys morrys closed this as completed Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants