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

replace object.assign by util.assign to make it work in IE #1643

Merged
merged 1 commit into from
May 2, 2017
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### vNEXT
- Feature+Fix: Introduce "standby" fetchPolicy to mark queries that are not currently active, but should be available for refetchQueries and updateQueries [PR #1636](https://github.com/apollographql/apollo-client/pull/1636)
- Feature: Print a warning when heuristically matching fragments on interface/union [PR #1635](https://github.com/apollographql/apollo-client/pull/1635)
- Fix: Replace usage of Object.assign with util.assign to make it work in IE, make util.assign work with undefined and null sources as Object.assign does [PR #1643](https://github.com/apollographql/apollo-client/pull/1643)

### 1.1.1
- Fix: Remove ability to set default fetchPolicy, which broke polling queries [PR #1630](https://github.com/apollographql/apollo-client/pull/1630)
Expand Down
7 changes: 4 additions & 3 deletions src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '../transport/Deduplicator';

import { isEqual } from '../util/isEqual';
import { assign } from '../util/assign';

import {
QueryListener,
Expand Down Expand Up @@ -258,7 +259,7 @@ export class QueryManager {
mutation = addTypenameToDocument(mutation);
}

variables = Object.assign(getDefaultValues(getMutationDefinition(mutation)), variables);
variables = assign({}, getDefaultValues(getMutationDefinition(mutation)), variables);

const mutationString = print(mutation);
const request = {
Expand Down Expand Up @@ -647,7 +648,7 @@ export class QueryManager {
if (queryDefinition.variableDefinitions && queryDefinition.variableDefinitions.length) {
const defaultValues = getDefaultValues(queryDefinition);

options.variables = Object.assign(defaultValues, options.variables);
options.variables = assign({}, defaultValues, options.variables);
}

if (typeof options.notifyOnNetworkStatusChange === 'undefined') {
Expand Down Expand Up @@ -844,7 +845,7 @@ export class QueryManager {
transformedDoc = addTypenameToDocument(transformedDoc);
}

const variables = Object.assign(getDefaultValues(getOperationDefinition(query)), options.variables);
const variables = assign({}, getDefaultValues(getOperationDefinition(query)), options.variables);

const request: Request = {
query: transformedDoc,
Expand Down
4 changes: 3 additions & 1 deletion src/queries/getFromAST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
valueToObjectRepresentation,
} from '../data/storeUtils';

import { assign } from '../util/assign';

export function getMutationDefinition(doc: DocumentNode): OperationDefinitionNode {
checkDocument(doc);

Expand Down Expand Up @@ -250,7 +252,7 @@ export function getDefaultValues(definition: OperationDefinitionNode): { [key: s
return defaultValueObj;
});

return Object.assign({}, ...defaultValues);
return assign({}, ...defaultValues);
}

return {};
Expand Down
12 changes: 9 additions & 3 deletions src/util/assign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ export function assign (
target: { [key: string]: any },
...sources: Array<{ [key: string]: any }>,
): { [key: string]: any } {
sources.forEach(source => Object.keys(source).forEach(key => {
target[key] = source[key];
}));
sources.forEach(source => {

if (typeof(source) === 'undefined' || source === null) {
return;
}
Object.keys(source).forEach(key => {
target[key] = source[key];
});
});
return target;
}