-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix(common): manual impl Default for FeatureFlags
to align FeatureFlags::default()
with Serde per-field default
#5064
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
Hi @ansemb! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
@@ -6,7 +6,7 @@ query spreadOfAssignableFragmentQuery { | |||
...spreadOfAssignableFragmentAssignable_node | |||
} | |||
node2: node(id: 5) { | |||
...spreadOfAssignableFragmentAssignable_user | |||
# ...spreadOfAssignableFragmentAssignable_user |
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.
Running this test is failing with @alias
error:
✖ Expected `@alias` directive. `spreadOfAssignableFragmentAssignable_user` is defined on `User` which might not match this selection type of `Node`. Add `@alias` to this spread to expose the fragment reference as a nullable property.
spread-of-assignable-fragment.graphql:9:8
8 │ node2: node(id: 5) {
9 │ ...spreadOfAssignableFragmentAssignable_user
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10 │ ...spreadOfAssignableFragmentAssignable_node
However, when adding an @alias
we get this error:
✖ Because an assignable fragment was spread in this linked field, each of this linked field's selections must be an inline fragment with no directives, refining the type to a unique concrete type and containing an unaliased __typename field with no directives. However, an inline fragment in this linked field contains directives.
spread-of-assignable-fragment.graphql:8:10
7 │ }
8 │ node2: node(id: 5) {
│ ^^^^
9 │ ...spreadOfAssignableFragmentAssignable_user @alias
✖ Because an assignable fragment was spread in this linked field, each of this linked field's selections must be an inline fragment with no directives, refining the type to a unique concrete type and containing an unaliased __typename field with no directives. However, an inline fragment in this linked field does not contain an unaliased __typename selection with no directives.
spread-of-assignable-fragment.graphql:8:10
7 │ }
8 │ node2: node(id: 5) {
│ ^^^^
9 │ ...spreadOfAssignableFragmentAssignable_user @alias
✖ Because an assignable fragment was spread in this linked field, this linked field can only contain inline fragments, and any inline fragments cannot have @skip or @include.
spread-of-assignable-fragment.graphql:10:8
9 │ ...spreadOfAssignableFragmentAssignable_user @alias
10 │ ...spreadOfAssignableFragmentAssignable_node
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 │ }
ℹ enclosing linked field
spread-of-assignable-fragment.graphql:8:10
7 │ }
8 │ node2: node(id: 5) {
│ ^^^^
9 │ ...spreadOfAssignableFragmentAssignable_user @alias
✖ The @alias directive is not allowed on assignable fragment spreads.
spread-of-assignable-fragment.graphql:9:50
8 │ node2: node(id: 5) {
9 │ ...spreadOfAssignableFragmentAssignable_user @alias
│ ^^^^^^
10 │ ...spreadOfAssignableFragmentAssignable_node
For now I've removed this spread, but I'm ot sure what the prefered solution is.
@evanyeung has imported this pull request. If you are a Meta employee, you can view this in D81642130. |
@evanyeung merged this pull request in be2c2a0. |
Fixes #5063
Problem
enforce_fragment_alias_where_ambiguous
wasEnabled
only when deserialized via Serde (using#[serde(default = "enabled_feature_flag")]
), butFeatureFlags::default()
producedDisabled
because#[derive(Default)]
ignores Serde attributes.This was the reason that adding an empty object to the
featureFlags
enabled theenforce_fragment_alias_where_ambiguous
, but omitting it didn't:Changes
Default
forFeatureFlags
that setsenforce_fragment_alias_where_ambiguous
toFeatureFlag::Enabled
and leaves all other fields at their existing defaults.PartialEq
forFeatureFlags
,FeatureFlag
,Rollout
andRolloutRange
to enable object equality in tests.NOTE: This is probably a breaking change, since we're now (actually) enabling the flag by default.
Tests
Updated/added unit tests in feature_flags.rs:
default_trait_sets_enforce_fragment_alias_enabled
ensures the Rust default enables the field (could be omitted?).serde_default_from_empty_object_matches_intent
asserts deserializing{}
equalsFeatureFlags::default()
.