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

Respect variables with no value provided #1195

Merged
merged 1 commit into from
Dec 9, 2021

Conversation

guymers
Copy link
Contributor

@guymers guymers commented Dec 9, 2021

When resolving a value for a variable, if a value has not been provided
and it has no default then do not include it instead of setting it to
null.

When resolving a value for a variable, if a value has not been provided
and it has no default then do not include it instead of setting it to
`null`.
@ghostdogpr ghostdogpr requested a review from frekw December 9, 2021 05:34
case value: Value => value
for {
definition <- variableDefinitions.find(_.name == name)
value <- variableValues.get(name).orElse(definition.defaultValue)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit 💅 : getOrElse

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definition.defaultValue is an Option so getOrElse is not applicable?

Copy link
Owner

@ghostdogpr ghostdogpr Dec 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think you're right

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But so is variableValues.get(name) since you're getting it from a map, right?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frekw getOrElse expects an A, but defaultValue is an Option[A]. It's orElse, not getOrElse.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in either case, doesn't matter much.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, b is of type Any if you do that :P

https://scastie.scala-lang.org/YjZ63y0XRXSxAMGDC6K65Q

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And also 🤦 I guess

Copy link
Collaborator

@frekw frekw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! ⭐

@ghostdogpr
Copy link
Owner

Thanks!

@ghostdogpr ghostdogpr merged commit 98b1769 into ghostdogpr:master Dec 9, 2021
Fluxx pushed a commit to Fluxx/caliban that referenced this pull request Jan 24, 2022
When resolving a value for a variable, if a value has not been provided
and it has no default then do not include it instead of setting it to
`null`.
Fluxx pushed a commit to Fluxx/caliban that referenced this pull request Jan 27, 2022
When resolving a value for a variable, if a value has not been provided
and it has no default then do not include it instead of setting it to
`null`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants