Skip to content

Commit

Permalink
fix: update state when calling mutate (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
FiodorGherasimenco authored Jan 16, 2023
1 parent a46e712 commit 1ca874b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1>
Messages
</h1>
<span />
<span>
executing
</span>
<button>
Add
</button>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1>
Messages
</h1>
<span>
Hello
</span>
<span />
<button>
Add
</button>
8 changes: 5 additions & 3 deletions src/components/gql-mutation/index.marko
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ $ const { renderBody, mutation, requestPolicy } = input;
<${renderBody}(
(variables, options) => {
const { client } = window.$$GQL || (window.$$GQL = createClient({}));
state.fetching = true;
component.setState("fetching", true);
return client
.mutation(mutation, variables, { requestPolicy, ...options })
.toPromise()
.then((results) => {
state.results = results;
state.fetching = false;
component.setState({
results,
fetching: false,
});
return results;
});
},
Expand Down

0 comments on commit 1ca874b

Please sign in to comment.