-
Notifications
You must be signed in to change notification settings - Fork 12
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
Deprecate unsetFields Behavior #49
Conversation
graphql-activerecord.gemspec
Outdated
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec| | |||
|
|||
spec.add_runtime_dependency "activesupport", ">= 4.2", '< 6' | |||
spec.add_runtime_dependency "activerecord", ">= 4.2", '< 6' | |||
spec.add_runtime_dependency "graphql", ">= 1.5.10", '< 2' | |||
spec.add_runtime_dependency "graphql", ">= 1.7.5", '< 2' |
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.
@theorygeek, just curiosity, is this what causes the change from type Foo implements Bar, Baz { field: Type }
to type Foo implements Bar & Baz { field: Type }
in the resulting schema?
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.
probably....
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.
LGTM
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.
LGTM
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.
@theorygeek - awesome
When you use
GraphQL::Models.define_mutator
to help build a mutation, you are given two options for handling null input values::set_null
will set any null input value to null:leave_unchanged
will leave any null input value alone. If you really meant to set it to null, you put the field's name into an array calledunsetFields
, and it will be set to null.This somewhat odd behavior comes from the fact that at the time the gem was written, the GraphQL language did not have support for distinguishing between implicit and explicit
null
values. Well, support for that feature has been in GraphQL for a long time now.This PR changes mutators so that they will respect the distinction between:
null
If you explicitly provide the value
null
, the corresponding attribute on your model is set tonil
. However, if you do not provide any value, the attribute is left unchanged.This is now the default behavior for new mutations, but you can get back to the old behavior by either:
legacy_nulls: true
when defining your mutator, orGraphQL::Models.legacy_nulls = true
before defining any mutators (ie, in an initializer)TODO: