Skip to content

Commit

Permalink
Create and expose MutateOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilkisiela committed Nov 2, 2016
1 parent 0290b7d commit 81f4b6e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Expect active development and potentially significant breaking changes in the `0

### vNext
- **new Feature**: Enable chaining of `use` and `useAfter` function calls in network interface. [PR #860](https://github.com/apollostack/apollo-client/pull/860) [Issue #564](https://github.com/apollostack/apollo-client/issues/564)
- Create and expose the `MutationOptions` [PR #866](https://github.com/apollostack/apollo-client/pull/866)

### v0.5.0
- Add a `createdBatchingNetworkInterface` function and export it.
Expand Down
16 changes: 2 additions & 14 deletions src/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import {
} from './transport/networkInterface';

import {
Document,
FragmentDefinition,

// We need to import this here to allow TypeScript to include it in the definition file even
// though we don't use it. https://github.com/Microsoft/TypeScript/issues/5711
// We need to disable the linter here because TSLint rightfully complains that this is unused.
Expand Down Expand Up @@ -46,16 +43,15 @@ import {
import {
DeprecatedWatchQueryOptions,
DeprecatedSubscriptionOptions,
MutateOptions,
} from './core/watchQueryOptions';

import {
IdGetter,
} from './data/extensions';

import {
MutationBehavior,
MutationBehaviorReducerMap,
MutationQueryReducersMap,
} from './data/mutationResults';

import {
Expand Down Expand Up @@ -329,15 +325,7 @@ export default class ApolloClient {
* for this, you can simply refetch the queries that will be affected and achieve a consistent
* store once these queries return.
*/
public mutate(options: {
mutation: Document,
variables?: Object,
resultBehaviors?: MutationBehavior[],
fragments?: FragmentDefinition[],
optimisticResponse?: Object,
updateQueries?: MutationQueryReducersMap,
refetchQueries?: string[],
}): Promise<ApolloQueryResult> {
public mutate(options: MutateOptions): Promise<ApolloQueryResult> {
this.initStore();

// We add the fragments to the document to pass only the document around internally.
Expand Down
12 changes: 12 additions & 0 deletions src/core/watchQueryOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {

import {
OperationResultReducer,
MutationBehavior,
MutationQueryReducersMap,
} from '../data/mutationResults';

/**
Expand Down Expand Up @@ -100,3 +102,13 @@ export interface DeprecatedSubscriptionOptions {
variables?: { [key: string]: any };
fragments?: FragmentDefinition[];
};

export interface MutateOptions {
mutation: Document;
variables?: Object;
resultBehaviors?: MutationBehavior[];
fragments?: FragmentDefinition[];
optimisticResponse?: Object;
updateQueries?: MutationQueryReducersMap;
refetchQueries?: string[];
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {

import {
WatchQueryOptions,
MutateOptions,
} from './core/watchQueryOptions';

import {
Expand Down Expand Up @@ -94,6 +95,7 @@ export {

// internal type definitions for export
WatchQueryOptions,
MutateOptions,
ObservableQuery,
MutationBehavior,
MutationQueryReducersMap,
Expand Down

0 comments on commit 81f4b6e

Please sign in to comment.