Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
Add createRequest to updateQuery for parsing strings (#72)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten authored and JoviDeCroock committed Sep 9, 2019
1 parent 91cd962 commit 71d7f97
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/store.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import invariant from 'invariant';
import { DocumentNode } from 'graphql';
import { createRequest } from 'urql';
import * as Pessimism from 'pessimism';

import {
Expand Down Expand Up @@ -252,12 +253,13 @@ export class Store {
}

updateQuery(
ctx: { query: DocumentNode; variables?: Variables },
input: { query: string | DocumentNode; variables?: Variables },
updater: (data: Data | null) => null | Data
): void {
const output = updater(read(this, ctx).data);
const request = createRequest(input.query, input.variables);
const output = updater(read(this, request).data);
if (output !== null) {
startWrite(this, ctx, output);
startWrite(this, request, output);
}
}

Expand Down

0 comments on commit 71d7f97

Please sign in to comment.