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

Generate commitLocalPayload for elgible queries #118

Merged
merged 3 commits into from
Oct 24, 2020
Merged

Conversation

zth
Copy link
Owner

@zth zth commented Oct 23, 2020

This generates a commitLocalPayload for any query annotated with @raw_response_type, which lets you easily commit local only data in a type safe way as if it were an actual server response. This can be used for a bunch of things, most notably local state management via Relay.

The API looks roughly like this:

module Query = [%relay.query {|
  query SomeQuery {
    loggedInUser {
      lastActiveAt
    }
  }
|}];

...

Query.commitLocalPayload(~environment, ~variables=(), ~payload={ loggedInUser: { lastActive: someTimestamp } });

Check out the added test in this diff for another example/more info.

@zth zth merged commit 342b2e6 into master Oct 24, 2020
@zth zth deleted the commit-local-payload branch October 24, 2020 20:15
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

Successfully merging this pull request may close these issues.

1 participant