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

rename action types #222

Merged
merged 2 commits into from
May 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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