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

Allowing null values #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# graphqlify-null

Fork of `graphqlify` that allows sending null values. Because who knows if [#8](https://github.com/kadirahq/graphqlify/pull/8) will ever be merged.

# graphqlify

This module helps you build GraphQL queries using plain JavaScript objects. This can be useful when you need to programmatically build GraphQL queries. Install the module from npm to get started.
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
{
"name": "graphqlify",
"name": "graphqlify-null",
"version": "1.1.0",
"description": "Build GraphQL queries with JavaScript",
"description": "Build GraphQL queries with JavaScript (fork of graphqlify)",
"main": "lib/index.js",
"scripts": {
"prepublish": "nofat make",
"test": "nofat test && nofat lint"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kadirahq/graphqlify.git"
"url": "git+https://github.com/Eiskis/graphqlify.git"
},
"keywords": [
"graphql"
],
"author": "Kadira Inc.",
"author": "Eiskis",
"license": "MIT",
"bugs": {
"url": "https://github.com/kadirahq/graphqlify/issues"
"url": "https://github.com/Eiskis/graphqlify/issues"
},
"homepage": "https://github.com/kadirahq/graphqlify#readme",
"homepage": "https://github.com/Eiskis/graphqlify#readme",
"devDependencies": {
"nofat": "^2.0.0"
}
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function encodeParamsMap(params) {
const val = params[key];
return params.hasOwnProperty(key) &&
val !== undefined &&
val !== null &&
// val !== null &&
!Number.isNaN(val);
});

Expand All @@ -247,6 +247,9 @@ function encodeParam(key, val) {
// Enum('a') => 'a'
//
function encodeParamValue(value) {
if (value === null) {
return null;
}
if (Array.isArray(value)) {
return encodeParamsArray(value);
}
Expand Down