Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

fixes variable default to null, where it should be undefiend #3056

Merged
merged 9 commits into from
May 28, 2019
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
3 changes: 3 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

- Removed leftover `apollo-client@beta` peer dep. <br/>
[@brentertz](https://github.com/brentertz) in [#3064](https://github.com/apollographql/react-apollo/pull/3064)
- Stop setting optional input to `null`, when using the `graphql` HOC. <br/>
[@ZhengYuTay](https://github.com/ZhengYuTay) in [#3056](https://github.com/apollographql/react-apollo/pull/3056)


## 2.5.6 (2019-05-22)

Expand Down
7 changes: 2 additions & 5 deletions src/hoc-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ export function getDisplayName<P>(WrappedComponent: React.ComponentType<P>) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
}

export function calculateVariablesFromProps<TProps>(
operation: IDocumentDefinition,
props: TProps,
) {
export function calculateVariablesFromProps<TProps>(operation: IDocumentDefinition, props: TProps) {
let variables: OperationVariables = {};
for (let { variable, type } of operation.variables) {
if (!variable.name || !variable.name.value) continue;
Expand All @@ -30,7 +27,7 @@ export function calculateVariablesFromProps<TProps>(

// Allow optional props
if (type.kind !== 'NonNullType') {
variables[variableName] = null;
variables[variableName] = undefined;
}
}
return variables;
Expand Down
2 changes: 1 addition & 1 deletion test/client/graphql/queries/api.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe('[queries] api', () => {
}
}
`;
const vars1 = { cursor: null };
const vars1 = { cursor: undefined };
const data1 = {
allPeople: { cursor: 1, people: [{ name: 'Luke Skywalker' }] },
};
Expand Down