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

Improve documentation around updating with mutation data #225

Open
outerlook opened this issue Jun 11, 2021 · 2 comments
Open

Improve documentation around updating with mutation data #225

outerlook opened this issue Jun 11, 2021 · 2 comments

Comments

@outerlook
Copy link

outerlook commented Jun 11, 2021

Hi!

I would like to contribute writing some guides on docs for some operations around mutating data with mutation responses.

The topics I first though of are:

  • Updating data once a request is complete (append data, remove data, edit data)
    • with refetch
    • with setCache
    • with assignSelections
  • optimisticResponse

But I still didn't get how to do it all. Then I'll continue to understand this better while I rebuild my app to use svelte + gqless.

In meantime, do you have any other suggestion of topics I could improve on the docs around recipes we see on other graphql clients?

Are there any known limitations I don't know yet but you do?

Great current docs anyway, but I know it is an extensive work. :)

References

Apollo mutations
Apollo optimistic update
Relay mutations
Urql cache mutations

@nemonemi
Copy link

nemonemi commented Jun 25, 2021

Hi, @outerlook,
I guess you've gone through the source code and found out how the API should behave and want to share it with the rest of the world?
I agree that docs are nice, and they could definitely use some work to make them more easily consumable.

I'm in a situation where I am creating an item in a list and I want to update the said list.
The docs suggest doing this via the refetchQueries, however, I'd prefer to simply update the cached query with the newly created item, and since I'm also returning the newly created item as a response, this would be my preferred approach.

I guess setCache should help achieve this, but it is not clear to me how to use it.

Do you have any hints for me?

In regards to how to contribute to the documentation, have you had a chance to see this page https://gqless.com/contributing?

@outerlook
Copy link
Author

Sure! Right now I'm migrating an entire codebase from react to svelte, and after that I would like to contribute with something around svelte bindings or something about docs.

Right now, my lastest solution was to build sort of a autoRefetchObjectQueries(typename, id) that refetches all queries on currently mounted components around an object identifier (type + id).

Then when I mutate some list, I refetch its parent queries. That is less performant than to surgically add an edge to a list, indeed. But right now I'm not running on any performance issue and it is really easy and manageable.

I can share my code for it later if you are interested on this.

If you are using react with gqless, I don't know for sure how you could access the currently mounted queries, because I only explored the core api and some hook. But it is not hard to follow the gqless useQuery code and try to figure out how to extend it.

Again, if this is some feature the library would like to offer, I would contribute as well.

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

2 participants