-
Notifications
You must be signed in to change notification settings - Fork 27
Explicit nulls on input types using InputValue wrapper #15
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
Conversation
The original PR had a deprecation strategy in place to prevent exisiting API breakage. Is it missing here or will it be coming in subsequent PRs? |
The generated part of the case .defined(let identifier):
if let identifier = identifier {
fields.append("identifier:\(GraphQL.quoteString(input: identifier))")
} else {
fields.append("identifier:null")
}
case .undefined: break Can be simplified it to this: case .defined(let identifier): fields.append("identifier:\(GraphQL.quoteString(input: identifier ?? "null"))")
case .undefined: break |
case .defined(let identifier): fields.append("identifier:\(GraphQL.quoteString(input: identifier ?? "null"))")
case .undefined: break ☝️ This would send the string |
Right. How about: case .defined(let identifier): fields.append("identifier:\(identifier == nil ? "null" : GraphQL.quoteString(input: identifier))")
case .undefined: break A little "busy" but will save a bunch of lines in generated code. |
case .defined(let identifier): fields.append("identifier:\(identifier == nil ? "null" : GraphQL.quoteString(input: identifier))") ☝️ That doesn't unwrap the optional though. Of course we could force unwrap after checking if it's |
Yeah it was meant to force-unwrap. It save 5 lines of generated code per field. Could be quite a lot depending on number of fields per class. |
0f75504
to
bebe5a1
Compare
It's also important to consider that these breaking changes directly impact Mobile Buy SDK. Can we not just modify #14 to comply with the Ruby style and add functionality for injecting file headers, etc? |
Can we discuss here @g-Off ? |
Sure, didn't realize there was an already open discussion going on in GitHub |
#14 has all the changes we made for Buy SDK, which will inevitably benefit Mobile Shopify. It needs to be massaged slightly to be more Ruby-like and add support for file header injection. |
Can we ship this and the rest of the changes in #14 as individual PRs? 14 has multiple independent things lumped together, ideally they are each shipped separately |
If we're okay splitting the commit into individual PRs, then yes. It gets hairy trying to split changes from a single commit. |
Also, it relies on the existing |
The double optional, correct? If so then I vote we rollback that change anyways and then go from there.
I would like to see the independent changes shipped as independent PRs |
Is there a reason not to ship this PR to cover the case of the InputValue type? As far as I can see this is ready to go, does what we want it to do in order to handle the nil/undefined and includes tests |
support/Sources/GraphQL.swift
Outdated
case undefined | ||
|
||
@available(*, deprecated, message: "Use `?? .undefined` instead") | ||
public init(orUndefined optional: Optional<T>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InputValue didn't exist before, so why add a deprecated initializer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That probably shouldn't be there.
Double optional shouldn't be there.
This introduces breaking changes into |
There are 4 PRs in place now that add the SDK changes incrementally:
@BenEmdon If the Ruby style isn't ideal, at this point it seems much simpler to fix that after it's merged so we can unblock the Mobile Buy SDK. The SDK relies on the changes for the next release, preferably sooner rather than later. |
3c8b7d2
to
561a56e
Compare
561a56e
to
4ea3007
Compare
- value(T?) - undefined
UpdateThe new InputValue wrapper is defined as: public enum Input<T> {
// Serialzeable value
case value(T?)
// Not serializable
case undefined
public init(orUndefined optional: Optional<T>) {
if let value = optional {
self = .value(value)
} else {
self = .undefined
}
}
} |
@dbart01 is there anything stopping this PR anymore? |
This PR
This is a competing PR with #12. This proposal takes out the explicit null logic in #14.
The aim of this PR is to allow you to set explicit
null
values on nullable properties on input types.#{propertyName}seen
observers triggered ondidSet
.InputValue
to GraphQL.swiftNew input types are in the form:
API Breakage
The new change causes some API breakage.
Closes #12