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

readField functions first argument #7916

Closed
BayCo opened this issue Mar 29, 2021 · 2 comments
Closed

readField functions first argument #7916

BayCo opened this issue Mar 29, 2021 · 2 comments

Comments

@BayCo
Copy link

BayCo commented Mar 29, 2021

My cached object has data({"path":"$.caption.text"}) key with text value in it.
I can't access it using readField('data({"path":"$.caption.text"})', item)
The other fields like id or created_at are accessible.

@benjamn
Copy link
Member

benjamn commented Mar 29, 2021

@BayCo I realize this API is under-documented (cc @StephenBarlow and @hwillson), but I have good news: the readField helper can also take ReadFieldOptions, like so:

readField({
  fieldName: "data"
  args: { path: "$.caption.text" },
  from: item,
})

Doing it this way will automatically reuse the same logic that originally serialized the arguments, so you don't have to worry about doing any serialization or string manipulation yourself.

This ReadFieldOptions API was first implemented in #6306, and released in @apollo/[email protected], so it's safe to use with any version of AC3.

@BayCo
Copy link
Author

BayCo commented Mar 30, 2021

@benjamn it works, thank you for your explanation :-)

@BayCo BayCo closed this as completed Mar 30, 2021
@benjamn benjamn added this to the Docs updates milestone Mar 31, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants