HoudiniGraphql / houdini

The disappearing GraphQL framework
http://www.houdinigraphql.com
MIT License
898 stars 95 forks source link

Optimistic updates with fake IDs #246

Closed AlecAivazis closed 2 months ago

AlecAivazis commented 2 years ago

When a user is submiting an optimistic update, their payload won't know the correct id to provide for a new element that they want to add to some list. This might create some weirdness if the optimisic id is used as the input for a mutation. Ideally, the cache would be able to recognize that the id being used as a mutation input and block the requests until the original mutation resolves and provides a correct id.

This feature could be opted into by asking for the id of the mutation payload explicitly. There would have to be a way for the generators to identify that id wasn't asked for by a transformation.

AlecAivazis commented 3 months ago

Here's where I'm at right now with the api:

mutation CreateItem {
  createItem {
    item { 
      id @optimisticKey
      text

      ...All_Items_insert
    }
  }
}