Skip to content

Commit

Permalink
Merge pull request #222 from apollostack/ActionTypes
Browse files Browse the repository at this point in the history
rename action types
  • Loading branch information
Sashko Stubailo committed May 17, 2016
2 parents a3fc6f7 + 3fe53ab commit 39633ab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Expect active development and potentially significant breaking changes in the `0

### vNEXT

- Namespace Apollo action types to prevent collision with user's own Redux action types. [Issue #210](https://github.com/apollostack/apollo-client/issues/210) [PR #222](https://github.com/apollostack/apollo-client/pull/222)

### v0.3.8

- Add support for [GraphQLJSON](https://github.com/taion/graphql-type-json) scalar type by changing the way we identify scalar types when writing to the store. [Issue #217](https://github.com/apollostack/apollo-client/issues/217) [PR #219](https://github.com/apollostack/apollo-client/pull/219)
Expand Down
14 changes: 7 additions & 7 deletions src/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class QueryManager {
} as Request;

this.store.dispatch({
type: 'MUTATION_INIT',
type: 'APOLLO_MUTATION_INIT',
mutationString,
mutation: {
id: 'ROOT_MUTATION',
Expand All @@ -154,7 +154,7 @@ export class QueryManager {
return this.networkInterface.query(request)
.then((result) => {
this.store.dispatch({
type: 'MUTATION_RESULT',
type: 'APOLLO_MUTATION_RESULT',
result,
mutationId,
});
Expand Down Expand Up @@ -310,7 +310,7 @@ export class QueryManager {

// Initialize query in store with unique requestId
this.store.dispatch({
type: 'QUERY_INIT',
type: 'APOLLO_QUERY_INIT',
queryString,
query: querySS,
minimizedQueryString,
Expand All @@ -332,14 +332,14 @@ export class QueryManager {
.then((result: GraphQLResult) => {
// XXX handle multiple GraphQLResults
this.store.dispatch({
type: 'QUERY_RESULT',
type: 'APOLLO_QUERY_RESULT',
result,
queryId,
requestId,
});
}).catch((error: Error) => {
this.store.dispatch({
type: 'QUERY_ERROR',
type: 'APOLLO_QUERY_ERROR',
error,
queryId,
requestId,
Expand All @@ -349,7 +349,7 @@ export class QueryManager {

if (! minimizedQuery || returnPartialData) {
this.store.dispatch({
type: 'QUERY_RESULT_CLIENT',
type: 'APOLLO_QUERY_RESULT_CLIENT',
result: {
data: initialResult,
},
Expand Down Expand Up @@ -391,7 +391,7 @@ export class QueryManager {
}

this.store.dispatch({
type: 'QUERY_STOP',
type: 'APOLLO_QUERY_STOP',
queryId,
});
}
Expand Down
28 changes: 14 additions & 14 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,29 @@ import {
} from './queries/store';

export interface QueryResultAction {
type: 'QUERY_RESULT';
type: 'APOLLO_QUERY_RESULT';
result: GraphQLResult;
queryId: string;
requestId: number;
}

export function isQueryResultAction(action: ApolloAction): action is QueryResultAction {
return action.type === 'QUERY_RESULT';
return action.type === 'APOLLO_QUERY_RESULT';
}

export interface QueryErrorAction {
type: 'QUERY_ERROR';
type: 'APOLLO_QUERY_ERROR';
error: Error;
queryId: string;
requestId: number;
}

export function isQueryErrorAction(action: ApolloAction): action is QueryErrorAction {
return action.type === 'QUERY_ERROR';
return action.type === 'APOLLO_QUERY_ERROR';
}

export interface QueryInitAction {
type: 'QUERY_INIT';
type: 'APOLLO_QUERY_INIT';
queryString: string;
query: SelectionSetWithRoot;
minimizedQueryString: string;
Expand All @@ -42,49 +42,49 @@ export interface QueryInitAction {
}

export function isQueryInitAction(action: ApolloAction): action is QueryInitAction {
return action.type === 'QUERY_INIT';
return action.type === 'APOLLO_QUERY_INIT';
}

export interface QueryResultClientAction {
type: 'QUERY_RESULT_CLIENT';
type: 'APOLLO_QUERY_RESULT_CLIENT';
result: GraphQLResult;
complete: boolean;
queryId: string;
}

export function isQueryResultClientAction(action: ApolloAction): action is QueryResultClientAction {
return action.type === 'QUERY_RESULT_CLIENT';
return action.type === 'APOLLO_QUERY_RESULT_CLIENT';
}

export interface QueryStopAction {
type: 'QUERY_STOP';
type: 'APOLLO_QUERY_STOP';
queryId: string;
}

export function isQueryStopAction(action: ApolloAction): action is QueryStopAction {
return action.type === 'QUERY_STOP';
return action.type === 'APOLLO_QUERY_STOP';
}

export interface MutationInitAction {
type: 'MUTATION_INIT';
type: 'APOLLO_MUTATION_INIT';
mutationString: string;
mutation: SelectionSetWithRoot;
variables: Object;
mutationId: string;
}

export function isMutationInitAction(action: ApolloAction): action is MutationInitAction {
return action.type === 'MUTATION_INIT';
return action.type === 'APOLLO_MUTATION_INIT';
}

export interface MutationResultAction {
type: 'MUTATION_RESULT';
type: 'APOLLO_MUTATION_RESULT';
result: GraphQLResult;
mutationId: string;
}

export function isMutationResultAction(action: ApolloAction): action is MutationResultAction {
return action.type === 'MUTATION_RESULT';
return action.type === 'APOLLO_MUTATION_RESULT';
}

export type ApolloAction =
Expand Down

0 comments on commit 39633ab

Please sign in to comment.