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

cache.resolveFieldByKey is deprected #42

Open
aseerkt opened this issue Sep 9, 2021 · 6 comments
Open

cache.resolveFieldByKey is deprected #42

aseerkt opened this issue Sep 9, 2021 · 6 comments

Comments

@aseerkt
Copy link

aseerkt commented Sep 9, 2021

Deprecation notice of resolveFieldByKey - urql-graphql/urql#1219

cache.resolveFieldByKey is used in two places in cursorPagination

cache.resolveFieldByKey(entityKey, fieldKey) as string,

const key = cache.resolveFieldByKey(entityKey, fi.fieldKey) as string;

deprecation-fieldByKey

@aseerkt aseerkt changed the title cache.resolveFieldByKey is Deprected cache.resolveFieldByKey is deprected Sep 9, 2021
@senjufy
Copy link

senjufy commented Sep 12, 2021

Hey Ctrl + click on resolveFieldByKey and it will take you to types.d.ts. In this types file on line 70 is the resolveFieldByKey type and above it there is a @deprected sign just remove it. And if you data doesn't still load wait till the next section where he fixes the mock data and iy will work after it. Hope this helps.

@aseerkt
Copy link
Author

aseerkt commented Sep 13, 2021

@senjufy Thanks for the suggestion. You don't need to go as far as removing the @deprecated sign in types.d.ts file. As you can see from the above screenshot, just use resolve instead of resolveFieldByKey.

@aseerkt aseerkt closed this as completed Sep 13, 2021
@aseerkt
Copy link
Author

aseerkt commented Sep 13, 2021

Reopening for visibility to newcomers.

@aseerkt aseerkt reopened this Sep 13, 2021
@senjufy
Copy link

senjufy commented Sep 13, 2021

I did use resolve but wanted to stick with resolveFieldByKey just for the sake of continuation of the tutorial

@bugenzi
Copy link

bugenzi commented Oct 20, 2021

I did use resolve but wanted to stick with resolveFieldByKey just for the sake of continuation of the tutorial

The crust of it stays the same, and sometimes it is better to do it a bit differently.
You can see the source code of urlq cache.resolveFieldByKey has slapped on the resolve method.

@aronweston
Copy link

This worked for me for anyone that wants to copy/pasta

fieldInfos.forEach((fi) => {
      const key = cache.resolve(entityKey, fi.fieldKey) as string; 
      const data = cache.resolve(key, 'posts') as string[];
      const _hasMore = cache.resolve(key, 'hasMore');
      if (!_hasMore) hasMore = _hasMore as boolean;
      results.push(...data);
    });```

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

4 participants