julienvincent / modelizr

Generate GraphQL queries from models that can be mocked and normalized.
http://julienvincent.github.io/modelizr
176 stars 6 forks source link

buildParameters problem #14

Closed ming436534 closed 6 years ago

ming436534 commented 6 years ago
const buildParameters = (params: ?Object): string => {
    params = _.pickBy(params || {}, value => value !== null && value !== undefined && !Object.is(value, NaN))
    if (_.isEmpty(params)) return ""
    return `(${_.map(_.pickBy(params, param => param || param === false), (param, key) =>
        `${key}: ${JSON.stringify(param).replace(/"([^(")"]+)":/g, "$1:")}`)})`
}

May I ask what is the purpose of _.pickBy(params, param => param || param === false ? This part of code would omit my param if my param is like {page:0}. It makes problem as my pagination 0 based. May I ask if this is on purpose? Thank you.

julienvincent commented 6 years ago

Hmm that looks like a mistake. I think I meant to replace that line with the variable params created above.

Could you submit a PR?

ming436534 commented 6 years ago

@julienvincent I have created a PR #15, thank you.

julienvincent commented 6 years ago

Great! Published as 1.0.5