Skip to content

Commit

Permalink
Merge pull request #31 from wayfair-incubator/handle_null_args
Browse files Browse the repository at this point in the history
fix: handle null args
  • Loading branch information
mjfaga authored Aug 21, 2023
2 parents 8cac819 + b4c0552 commit 76c9190
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to

## [Unreleased]

## [v1.1.2] - 2023-08-21

### Fixed

- fix: handle null arguments

## [v1.1.1] - 2023-08-09

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wayfair/gqmock",
"version": "1.1.1",
"version": "1.1.2",
"description": "GQMock - GraphQL Mocking Service",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions src/seed/SeedManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ export default class SeedManager {
) {
const argsMatch = Object.entries(source).every(
([argumentName, argumentValue]) => {
if (typeof argumentValue === 'object') {
// null is an object, exclude it from this check
if (typeof argumentValue === 'object' && argumentValue != null) {
return this.matchArguments(argumentValue, target[argumentName]);
}
return isEqual(target[argumentName], argumentValue);
Expand All @@ -130,7 +131,8 @@ export default class SeedManager {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
private argumentCount(args: Record<string, any>) {
return Object.entries(args).reduce((acc, [, value]) => {
if (typeof value === 'object') {
// null is an object, exclude it from this check
if (typeof value === 'object' && value != null) {
return acc + this.argumentCount(value) + 1;
}

Expand Down

0 comments on commit 76c9190

Please sign in to comment.